When trying to access google translate api from an android application it gives the following error:
java.lang.RuntimeException: An error occurred while executing doInBackground()
....
Caused by: com.google.cloud.translate.TranslateException: Invalid Value
...
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid Value",
"reason" : "invalid"
} ],
"message" : "Invalid Value"
The code inside doInBackground method() is:
Translate translate = TranslateOptions.newBuilder()
.setApiKey("myAPI_key").build().getService();
Translation translation = translate.translate(
params[0],
Translate.TranslateOption.sourceLanguage("en"),
Translate.TranslateOption.targetLanguage("al"));
return translation.getTranslatedText(); }
The string I pass is in english. Can anyone help me figuring out this error? Thanks in advance.