20

I'm starting to use cloud endpoints in my GAE project but have been running into issues with the api not updating on the server.

  • localhost:8888/_ah/api/explorer is ok.

But when I deploy, nothing changes.

  • myapp.appspot.com:8888/_ah/api/explorer is bad

Further investigation shows the url end points update example: https://myapp.appspot.com/_ah/api/myapp/v1/foo/list

But the loaded client api is still incorrect. example: gapi.client.load('myapp', 'v1', callback, url); gapi.client.myapp.foo.list();

If I changed the call from foo/list to foo/list2, the rest url would update, the api package would not.

jrmerz
  • 698
  • 1
  • 10
  • 24

6 Answers6

22

I'll try to cover the two cases people could run into:

Client Side:

The Google APIs Explorer web app aggressively caches, so you'll need to clear your cache or force a refresh when you update your API server side to see the changes in the client.

Server Side (In Deployed Production App Engine App):

If you're having deployment issues, there are two places to look when debugging:

  • Check your Admin Logs (https://appengine.google.com/adminlogs?&app_id=s~YOUR-APP-ID) after deployment. After a successful deployment of your application code, you should see the message:

    Completed update of a new default version
    

    and shortly after that you should see:

    Successfully updated API configuration
    

    If you this message indicates the API configuration update failed, you should deploy again. If said error is persistent, you should notify us of a bug. If you don't see any message about your API configuration, you should check that the path /_ah/spi/.* is explicitly named in your routing config (app.yaml for Python, web.xml for Java).

  • Check your Application Logs (https://appengine.google.com/logs?&app_id=s~YOUR-APP-ID) after deployment. After the deployment finishes, Google's API infrastructure makes a request to /_ah/spi/BackendService.getApiConfigs in your application so that your API configuration (as JSON) can be registered with Google's API infrastructure and all the discovery-related configs can be created. If this request does not complete with a 200, then your API changes will not show up since Google's API infrastructure will have nothing to register.

  • If you are consistently getting a 302 redirect for requests to /_ah/spi/BackendService.getApiConfigs, it is because you (or your generated API config) have specified a "bns adapter" that uses http: as the protocol in your API root, but your web.xml (Java) or app.yaml (Python) is required that paths through /_ah/spi are secure. This will make requests using http: as the protocol be redirected (using 302) to the same page with https: as the protocol. This was discussed on the Trusted Tester forum before going to Experimental.

bossylobster
  • 9,993
  • 1
  • 42
  • 61
  • I develop with chrome. To be sure it wasn't a caching issue, I opened with Firefox as well as Safari, fresh loads. – jrmerz Feb 25 '13 at 02:02
  • I'm somewhat perplexed by your question. You refer to https://developers.google.com/apis-explorer/?base=http://localhost:8888/_ah/api#p/myapi/v1/, which points at a local app and then say "But when I deploy, nothing changes". Do you mean that nothing changes in GAE production? – bossylobster Feb 25 '13 at 22:21
  • 1
    So locally (http://localhost:8888/_ah/api/explorer, which redirects to posted url) everything looks great. But when I deploy to app engine, myapp.appspot.com/_ah/api/explorer does not update for some time. – jrmerz Feb 26 '13 at 04:38
  • Can you change your question to make this clearer? I'll post some pointers in my answer. – bossylobster Feb 26 '13 at 05:06
  • Ok. Will do. Sometimes asking the right question when you are in the dark is the hardest part :) Looks like point 2 is failing. /_ah/spi/BackendService.getApiConfigs 400 4461ms 0kb 10.157.42.14 - - [26/Feb/2013:07:30:00 -0800] "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 400 181 - - "myapp.appspot.com" ms=4462 cpu_ms=2469 cpm_usd=0.000020 loading_request=1 instance=00c61b117c7c89820ea148f3e6988874a5b2c233 – jrmerz Feb 26 '13 at 15:42
  • 1
    There should be a stacktrace from your failing code, can you post that in the question as well? Or even start a new question asking about the specific stacktrace? – bossylobster Feb 26 '13 at 16:59
  • There is no stacktrace in the logs. Sometimes the call to /_ah/spi/BackendService.getApiConfigs returns a 405. Also says "This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application." – jrmerz Feb 27 '13 at 05:20
  • OK, thinks seem to be working tonight. This is my process for updating . 1) Kill my local server. 2) call 'bin/endpoints.sh'. 3) Start local server. 4) Poke at localhost:8888/_ah/api/explorer with my browser to inspect all is well 5) deploy to app engine. Sometimes the api explorer window is cached in the browser but a call to grab the api package returns the latest. – jrmerz Feb 27 '13 at 06:00
  • Hi. I tried the above steps, and my admin and access logs look good. However, my updated methods are missing from `/_ah/api/discovery/v1/apis` on .appspot.com, while clearly updating on localhost:8888 . Anyone else still having this problem? Is a HTTP 302 OK for the `/_ah/spi/BackendService.getApiConfigs` line in the log? – Animesh Mar 06 '13 at 04:24
  • In a word: No. Can you start a new SO question about 302? It is a different issue and there is an explanation. Please post your `web.xml` there too. – bossylobster Mar 06 '13 at 04:37
  • Thanks @bossylobster. I got it to work BTW, also edited the answer with the fix. Given the title of this question, I did not want to create a separate SO question. – Animesh Mar 06 '13 at 04:57
  • 1
    @Animesh - I've edited the answer to remove the info about the 302. I feel it should be a separate question. Or if bossyLobster agrees, can edit it himself the way he wants the answer to be. The info you added should still be available in the Edit revisions of the post. – Tuxdude Mar 06 '13 at 05:01
  • @Tuxdude OK. I have added a new Qn at http://stackoverflow.com/questions/15246039/http-code-302-encountered-when-deploying-on-google-app-engine-endpoints/15246040#15246040 . Please feel free to update/answer/edit that. – Animesh Mar 06 '13 at 11:25
  • I have same issue with 1 additional detail: I'm using Guice for handling dependency injections. So if I use Guice - API gets updated only on local instance. If I switch back to writing /_ah/spi/* URL mapping in web.xml - API gets updated everywhere. – Herring Aug 04 '14 at 22:00
  • https://code.google.com/p/googleappengine/issues/detail?id=10635 there's the way how to fix API update with Guice DI used. – Herring Aug 04 '14 at 22:20
  • I recently updated to SDK v1.9.14. Now, in my logs, the call to /_ah/spi/BackendService.getApiConfigs is failing with error code 500: java.lang.NullPointerException at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:147)... – clocksmith Oct 28 '14 at 15:08
2

This is what happened to me.

I tested my endpoint on localhost and it worked fine.

I deployed my endpoint on appspot and when I made requests to it I received in the browser the message 'Not found'.

So I looked in the logs and when I made requests to the endpoint I saw a 404 http error code on favicon file. And in effects I forgot to put that file in my deploy.

So I redeployed my war with the favicon file, the 404 http code disappeared and the endpoint worked fine on appspot too!

I realize that this may sound silly, but it is what I experienced. (I apologize for my poor english)

demarcom
  • 131
  • 1
  • 3
1

I noticed that if you upload your app for the first time without the following in your web.xml:

 <security-constraint>
        <web-resource-collection>
            <url-pattern>/_ah/spi/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

Then your bns adapter will be set as http going forward. When I add the above afterwards, I get 302 http code on /_ah/spi/BackendService.getApiConfigs and the endpoints never update.

So now I have reverted to not use https on /_ah/spi and my endpoints are updating. I guess for those that see their endpoints not being updated revert back to the first configuration they had for ssl on /_ah/spi/.

Yaw.

Yaw Ly
  • 11
  • 1
0

I had the same error Not Found (the 404 error code) when I was calling my API using this URL

https: // MY_APP_ID.appspot.com / _ah / api / MY_SERVICE / v1 / user

I tried everything and finally fixed it by removing the discovery files from WEB-INF and kept only MY_SERVICE-v1.api and then redeployed the API. It works fine now.

user2292916
  • 261
  • 1
  • 4
  • 12
0

I was also getting stale API discovery doc after deploying new version, it took a couple of minutes for GAE to start serving the new one to me.

Ashish Awasthi
  • 1,302
  • 11
  • 23
0

I had the same problem, and I checked the admin logs, other logs etc... but still my API wasn't updating to the latest version.

So I decided to check in the API code for the last method I had written (I am writing in Java 7). And I found out that GAE doesn't like statements like:

if (!blocked){ .... }

I switched that to:

if (blocked == false) { ... }

And it worked like a charm. So by the looks of it, GAE scans the new API methods and doesn't accept some shortcuts.

piet.t
  • 11,718
  • 21
  • 43
  • 52