4

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.

dm78
  • 1,570
  • 1
  • 16
  • 28
  • 1
    Possible duplicate question http://stackoverflow.com/questions/14654758/google-places-api-request-denied-for-android-autocomplete-even-with-the-right-a – James McCracken Oct 03 '13 at 18:10

4 Answers4

1

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").

pushbit
  • 1,268
  • 9
  • 14
0

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

manishnath
  • 444
  • 1
  • 3
  • 12
-3

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
venu
  • 2,971
  • 6
  • 40
  • 59
  • 1
    There is already a sensor parameter being passed. I am not gathering data from a sensor, so I am passing it as false, as the API instructs me to do. I've read that page and tried requests similar to the examples already with no success. – dm78 Oct 03 '13 at 17:48