Rest API request for Google Translation API

Gabriela Pavlova picture Gabriela Pavlova · Sep 11, 2017 · Viewed 8.8k times · Source

I have a problem with Rest API request for Google Translation API

My POST method is https://translation.googleapis.com/language/translate/v2?key=MY_KEY

But I get an error

{
    "error": {
        "code": 400,
        "message": "API Key not found. Please pass a valid API key.",
        "errors": [
        {
            "message": "API Key not found. Please pass a valid API key.",
            "domain": "global",
            "reason": "badRequest"
        }
        ],
        "status": "INVALID_ARGUMENT"
    }
}

Please help me to understand where the problem comes from.

Answer

class picture class · Sep 19, 2017

You might want to try starting with one of the samples as opposed to trying to build your own client library or get/POST with REST. If you must use REST, the following example may be helpful:

https://translation.googleapis.com/language/translate/v2?key=your-key-here&q=cheese&target=es

Replace the API key with the one that you have enabled access to the translate API on.