Support Topics Documentation Slack YouTube Blog

Codeless API call to Google API - keyInvalid Usage Limits

(Paul Barnes) #1


I’m using Codeless with an APIService to call a google search api using the http block.

When I invoke the call, I am getting the following error:
“code”: 0,
“message”: “{“error”:{“errors”:[{“domain”:“usageLimits”,“reason”:“keyInvalid”,“message”:“Bad Request”}],“code”:400,“message”:“Bad Request”}}”

When I use the cURL statement generated by Backendless, I get the same error as above:
curl -X “GET” ““window%20suppliers”&cx=“004622423927607956040%3Aaqbe3g8agpg”&key=“AIzaSyDHSauVwSIwVs5boAuEgnXZJL4DcitzoKo”
-H ‘Content-Type: application/json’
-H ‘Accept: application/json’

I know that the API key I’m using is valid as the request to the google api directly in cURL works fine and returns the JSON from Google.

When I strip the %22 from the Backendless cURL command, it does work in cURL :
curl -X “GET” “
-H ‘Content-Type: application/json’
-H ‘Accept: application/json’

Can you please explain what I might be doing wrong ?


(Vladimir Upirov) #2

Hi Paul

“Request Query Params” block is an object which contains unparsed query params, that’s the reason why you are getting an error from google api.
Instead, you should add a “Create Object” block and set there all the parameters what you need: “q”, “cx”, “key” and etc…

replace this block:

with this:

Thanks, Vlad

(Paul Barnes) #3

Thank you! That worked.

The only thing is I can’t see method argument’s for context blocks for the other parameters I invoke the call with.

Is that the wrong pattern ?


(Vladimir Upirov) #4

There are two ways to get others parameters in the Codeless Editor:

  1. declare it in API Services section and context blocks will be there for the arguments
  2. or use it dynamically, but before use it convert it from String using “Convert to Object” block

(Paul Barnes) #5

Excellent. Thank you !