Search code examples
javascriptapigoogle-app-enginegoogle-cloud-endpointsclient-library

Google APIs Client Library for JavaScript - 404 on method call


Since this morning all my applications using gapi are down.

I'm using: https://apis.google.com/js/client.js

to communicate with the Endpoints of my Google Appengine applications, for example:

gapi.client.load('public', 'v2', function(){
    gapi.client.public.organizations().execute(function(response){ 
        console.log(response); 
    }); 
}, 'https://XXX.appspot.com/_ah/api');

As of today all calls are responded with the following error message:

[{"error":{"code":404,"message":"Not Found","data":[{"domain":"global","reason":"notFound","message":"Not Found"}]},"id":"gapiRpc"}]

My applications are not logging any errors. I can reach the Endpoint API explorer (/_ah/api/explorer) without errors. I can make HTTP-request calls without errors, e.g

https://XXX.appspot.com/_ah/api/public/v2/organizations

The "gapi"-object is loaded without errors. My "public" endpoint is also loaded and I can list all methods using the javascript console.

I have reported this error to Google.

Anybody else having this issue? Does anybody have any quick solutions or workarounds? Have I perhaps missed some Google updates or API-changes?

Thanks


Solution

  • It seems to be a general issue with the JS Client library at the moment, not limited to Endpoints APIs, but affecting all Google APIs.

    https://code.google.com/p/google-api-javascript-client/issues/detail?id=136

    Only real "work around" is not to depend on the JS Client Library (which had stability issues in the past as well) and construct the HTTP Requests yourself, which I know isn't a quick solution.

    You can also try using the gapi.client.request method for direct REST requests which seems to be working for one of my endpoints APIs. (again, not a quick solution, but probably better/easier since you still have the authentication working via the client library).

    gapi.client.request({
      "path": "/public/v2/organizations",
      "root": "https://XXX.appspot.com/_ah/api"
    }).execute(function (response) { 
      console.log(response); 
    });
    

    Edit: Update from the linked issue

    They will be rolling back the broken update which will take several hours to complete (no exact ETA yet).

    As a "quick" fix you can explicitely add the apiVersion to each request (careful: the B might change after the rollback, but it works now):

    var request = gapi.client.public.organizations();
    request.B.apiVersion = "v2";
    request.execute(function (response) {
      console.log(response);
    });
    

    Edit 2: Everything seems to be back to normal now.