Reputation: 31
I am using the Zomato API with R's httr package to get restaurant data in JSON. When I call the Zomato API using the following code block, I get some records back and the GET() call seems to work fine.
require(httr)
URL <- 'https://developers.zomato.com/api/v2.1/search?'
request <- GET(URL,
add_headers(User_key="#######_MY_API_KEY##############"),
query=list(entity_id = '94753',
entity_type = 'zone'))
content(request)
In the next code block, I make one modification to the code in order to do a text search. This API call returns 0 records, but it should return 2 - I know this because Zomato has an API testing tool at https://developers.zomato.com/documentation, which allows you to (among other things) enter your API key and some attribute values to generate API calls, and see the records returned.
I cannot understand why the following GET() returns 0 records. Suggestions?
request <- GET(URL,
add_headers(User_key="#######_MY_API_KEY##############"),
query=list(entity_id = '94753',
entity_type = 'zone',
q = 'border')) #added parameter and value
content(request)
Upvotes: 1
Views: 481
Reputation: 31
After reloading the R environment and running the script from scratch, it appears to work fine - the Get() call in the second block retrieves the 2 records that it should. I suspect that there was something I had set in the environment that was messing it up - perhaps epi99 was right, but just about another typo.
Upvotes: 0