App Inventor Http Get Request Not Working

I've been trying to make a simple get request to yelp-fusion for a while and nothing I do seems to work. I have a key and have been trying to set the authorization request header with different configurations (e.g. dictionaries, lists of lists, joining strings, putting them all in one etc.) I've seen a few other forums on here talking about similar issues but none of their solutions worked for me.
When I set it with a dictionary and use the Do-It option I get an error, error from companion: undefined variable (irritants: yail-yail/ dictionary)
The app seems to get stuck here as nothing after the set request headers block executes

When I set it with a list of lists I get an error, error 1111 request headers not valid: element 1 does not contain two elements.

I've tried adding another request header, but I get the same error. I've also tried putting 'bearer' and 'authorization key' as two elements of another list but that doesn't work. I've made sure to try it with a space between 'bearer' and 'key' and without. App inventor doesn't seem to like any of it.

With the list of lists, the get request goes through but in the gotText event handler I get the response content:

{"error": {"code": "VALIDATION_ERROR", "description": "Authorization is a required parameter.", "field": "Authorization", "instance": null}}

And a response code of 400

I'm also pretty sure I'm setting my url correctly according to the documentation on the yelp fusion website: https://api.yelp.com/v3/businesses/search?category=restaurants&lattitude=36.788&longitude=-119.77&radius=1000

Side note I do replace 'authorization key' with my API Key

I've also asked a friend to help, but he wasn't able to figure out what was wrong. He tried the same request in curl and it worked just fine for him (using my key), but I'm having no such luck in app inventor.

Any help would be greatly appreciated.

Set the request headers BEFORE setting the url and DO use the lists method to set headers.

Looks like you have it but ensure there is a space between Bearer and

What does the yelp api documentation say to do, for example with a curl request?

What is the link to the documentation?

Ok so I've made the following changes


I still get the app inventor error 1111, the response code 400 and the same response content,
{"error": {"code": "VALIDATION_ERROR", "description": "Authorization is a required parameter.", "field": "Authorization", "instance": null}}

On yelp's website it doesn't say anything about specific languages, only to do authorization through the authorization request header and how to set up the URL. This is the page I've been using

https://www.yelp.com/developers/documentation/v3/get_started

In my friends example he had another request header, Accept / but when I added it nothing changed

Forgive me for a dumb question, but
did you init a global variable with your actual authorization key?

If you did that, I would expect your header to include the global variable in place of that <...> boiler plate.

In your url latitude should only have two t's you have three ?

When I actually tested it I just put my whole key in the text block instead of just "authorization key".

Whoops yeah you're right. Though after changing it I unfortunately get the same errors.

The parameter "category" should be "categories" according to the documentation....

Yep.. ok so I fixed it and still nothing. When I was originally trying all this out I had it in a different project but it became such a mess that I hastily threw together a new one for this post hence the mistakes in the link sorry about that.

Hmmm, your headers and url do look OK.

Try with one of the examples given on the yelp documentation, see if any of those work.

Also, check that your API key is correct.

Test also your url in Postman or with curl

Ok so my API key should definitely be correct. There are underscores in it I don't know if that makes a difference. All the examples lead to the same errors. I don't actually know how to use Curl it was someone else I know that I asked and they used my key. I am currently setting up a postman account to try that out as well.

Also in the gotText event handler I just have this:

curl would be something like this:

curl -i  https://api.yelp.com/v3/businesses/search? \
categories=restaurants&latitude=36.788&longitude=-119.77&radius=1000 \
  -H "Authorization: Bearer <yourAPI key>"

latitude

lattitude: mood in response to too much milk in your coffee

The only other thing I could suggest is that you uriEncode your web1.url (use the block provided in the web component palette). No need to uriEncode the headers.

So I just put this into reqbin

curl -i https://api.yelp.com/v3/businesses/search?
term=delis&latitude=37.786882&longitude=-122.399972
-H "Authorization: Bearer umWaeHu0Lh8euhrrf69MdmWyRb_GwEWiMzivqL_wghsb3inFqvXYURRb-74dusO4M0Glce8cK2LmXXQxOuyLQe3wfTBRhXatTbiBAA7mCmXA3knbIft0I4Q8peDYX3Yx"

and for some reason its telling me that all my parameters are unsupported options and it gives a different response:

"error": {
"code": "VALIDATION_ERROR",
"description": "Please specify a location or a latitude and longitude"
}

Try with

curl -X GET  "https://api.yelp.com/v3/businesses/search? \
categories=restaurants&latitude=36.788&longitude=-119.77&radius=1000" \
  -H "Authorization: Bearer <yourAPI key>"

(sorry I left out the double quotes on the url)

It told me that it wasn't a correct curl command

remove the spaces and backslashes in the url and the one at the end after 1000"?

curl -X GET  "https://api.yelp.com/v3/businesses/search?categories=restaurants&latitude=36.788&longitude=-119.77&radius=1000"  -H "Authorization: Bearer <yourAPI key>"

Ok yes that went through and I got a bunch of data