Search code examples
javascribeyelp

Yelp API 400 Unavailable For Location Error


I have setup my request to the Yelp v2 search api using the location parameter passing in a full address to work using the scribe-java OAuth encoding code as given in the Java sample on their github repository.

I am testing a local address in the US to search but have been getting a 400 (UNAVAILABLE_FOR_LOCATION) through my application running on localhost.

The strange part is that the request works if I take the URL that my application generates (after OAuth signature) and paste it into the browser, the request succeeds and I see the data I need.

I have tried adding a user agent header to my request (which was my best guess as to why this behaviour would happen), but to no avail.

Has anyone ran across this error or have an idea as to how to solve this issue? The Yelp support Google group has been useless.


Solution

  • For those of you who have run into this same issue, the answer is that the Scribe library encodes spaces in the URL as %20 before sending.

    These entities aren't handled correctly by the Yelp API and end up being treated as a nonsense string for the location value. This is the reason why there was the UNAVAILABLE_FOR_LOCATION response. Replace the %20's with spaces again and it all will work fine.