Question

I have the same code (more or less) working fine in Java, but when I write it in javascript, I end up with 404's. I can't figure out what I'm doing wrong and it's driving me crazy!

    gapi.client.load('translate', 'v2', function () {
        gapi.client.language.languages.list().execute(function (response) {
            response.data.forEach(function(language){
                console.log(JSON.stringify(language));
            });
        });

"language":

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

I can see in the console the following POST data to https://content.googleapis.com/rpc?key=MY_API_KEY:

[{"jsonrpc":"2.0","id":"gapiRpc","method":"language.languages.list","apiVersion":"v1"}]

Should that say v1?

By contrast, the REST URL is https://www.googleapis.com/language/translate/v2/languages?key=MY_API_KEY (and it's a GET) and it works fine.

Was it helpful?

Solution

You are right that this was a bug in gapi.client.load. This bug has been fixed and you should no longer run into 404s.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top