I am testing Google Translate API via curl and it keeps asking for parameter q while it is already there in the URL (q=Hello%20World). Why is Google Translate API returning this error?
curl https://www.googleapis.com/language/translate/v2?key=&source=en&target=de&q=Hello%20World
[1] 16848
[2] 16849
[3] 16850
[2]- Done source=en
[3]+ Done target=de
foo:~ foo$ {
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: q",
"locationType": "parameter",
"location": "q"
},
{
"domain": "global",
"reason": "required",
"message": "Required parameter: target",
"locationType": "parameter",
"location": "target"
}
],
"code": 400,
"message": "Required parameter: q"
}
}
Help?
You have to surround your whole URL in double quotes, as in:
curl "https://www.googleapis.com/language/translate/v2?key=&source=en&target=de&q=Hello%20World"
Otherwise, your shell will interpret those &
characters before actually executing curl
; that's why you're seeing all these lines at the beginning:
[1] 16848
[2] 16849
[3] 16850
[2]- Done source=en
[3]+ Done target=de
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With