dm78
dm78

Reputation: 1600

Google Places API autocomplete - REQUEST_DENIED

I'm having a difficult time getting a valid autocomplete response from the Google Places API. I'm using code based on [their example}(https://developers.google.com/places/training/autocomplete-android) (which, interestingly is using a seemingly invalid country code of "uk").

I have enabled Places API in my Google Code Console. My API key was generated when I first enabled the Maps API a couple of weeks ago, and the MapFragment I'm using is working perfectly, so I have no reason to suspect that the API key is invalid.

The URL I'm using is https://maps.googleapis.com/maps/api/place/autocomplete/json?input=New+York&sensor=false&key=my_valid_api_key&components=country:us

I always get {"status":"REQUEST_DENIED","predictions":[]} as my response.

I have verified multiple times that my url is formed correctly and adheres to the requirements of the Places API autocomplete endpoint, yet I do not get the response I'm expecting.

I have seen a number of suggestions of how to fix this on SO and elsewhere, but none of them have worked for me (i.e.-using http instead of https, use port 443, etc.) I have tried these in all reasonable combinations with no change in the response.

Please help me find what I'm doing wrong.

Upvotes: 4

Views: 2633

Answers (4)

manishnath
manishnath

Reputation: 444

Use the server or browser key instead of the iOS key. Keep the refers field blank to allow all refers. Here is a sample project which does the same :https://github.com/manishnath/Autocomplete

Upvotes: 0

pushbit
pushbit

Reputation: 1268

I tried the URL you provided with my key and it returned the expected results. I suspect you are using an Android key instead of a Browser key. Try creating and using a Browser key (under "Simple API Access").

Upvotes: 1

venu
venu

Reputation: 2979

REQUEST_DENIED indicates that your request was denied, generally because of lack of a sensor parameter.try this

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Vict&types=geocode&language=fr&sensor=true&key=AddYourOwnKeyHere

Upvotes: -3

Related Questions