Hi all!
I'm trying to post, but I'm doing something wrong.
create a service account as indicated in the toturial and save the credential in GOOGLE_APLICATIONS_CREDENCIALS
Instructiones google API REST Translate:
HTTP method and URL:
POST https://translation.googleapis.com/language/translate/v2
JSON body of the request:
{
"q": ["Hello world"],
"target": "de"
}
Save the body of the request in a file called request.json and run the following command:
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
My code:
I'm sure this line is wrong, because I should be able to point to job1.GetRequest.SetHeader("Authorization","Bearer $(gcloud auth application-default print-access-token)") '<-- ITS BAD
I'm not sure this is solving it right either -d @ request.json
I appreciate you can help me
I'm trying to post, but I'm doing something wrong.
create a service account as indicated in the toturial and save the credential in GOOGLE_APLICATIONS_CREDENCIALS
Translating text (Basic) | Cloud Translation | Google Cloud
cloud.google.com
Instructiones google API REST Translate:
HTTP method and URL:
POST https://translation.googleapis.com/language/translate/v2
JSON body of the request:
{
"q": ["Hello world"],
"target": "de"
}
Save the body of the request in a file called request.json and run the following command:
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
My code:
B4X:
Dim translate As Map
translate.Initialize
translate.Put("q","hello word")
translate.Put("target","de")
Dim job1 As HttpJob
Dim jg As JSONGenerator
jg.Initialize(translate)
job1.Tag=jg
job1.Initialize("@request.json",Me)
job1.PostString("https://translation.googleapis.com/language/translate/v2",jg.ToString)
job1.GetRequest.SetHeader("Authorization","Bearer $(gcloud auth application-default print-access-token)") '<-- ITS BAD
job1.GetRequest.SetContentType("application/json;charset=UTF-8")
I'm sure this line is wrong, because I should be able to point to job1.GetRequest.SetHeader("Authorization","Bearer $(gcloud auth application-default print-access-token)") '<-- ITS BAD
I'm not sure this is solving it right either -d @ request.json
I appreciate you can help me