Rest API request for Google Translation API

18.1k Views Asked by At

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.

1

There are 1 best solutions below

3
On

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.