Android – Google places autocomplete api – REQUEST_DENIED

androidgoogle apigoogle-places-api

I'm creating app that use autocomplete places google api.

And I don't know what is wrong but all the time I got responses like:

{
    "predictions" : [],
    "status" : "REQUEST_DENIED"
}

I send req : https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Paris&types=geocode&language=fr&sensor=true&key=mykey

Documentation says :

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

I have sensor parameter, maybe it is something with api key.

Is there any page where can I get google's log :), to see why I got REQUEST_DENIED?

I use api key from :

http://code.google.com/intl/pl-PL/android/maps-api-signup.html

Maybe I have to get an api key from somewhere else.

Best Answer

You should be able to view your API Key by going to the API Console first: https://code.google.com/apis/console

If you haven't yet, you will need to create a new "Project" and then enable the Predictions services first by using the On/Off switch.

Please post your results, I have a similar problem with getting the REQUEST_DENIED response, but I've already got the API key and I'm using the sensor parameter like their documentation states.

It is frustrating that Google doesn't give any sort of response code along with REQUEST_DENIED so you can see why it's denying it. This will be difficult to support and troubleshoot in a production environment if this randomly goes out without providing any details as to why.

Update:

I just found this works for me now, but only after changing my requests to GET requests instead of POST. For reasons unknown, Google returns REQUEST_DENIED for POST requests but allows the same request via GET. A quick test for you to see if this is your problem would be to put the URL together with your API key and other parameters and try it through your browser instead. If that works then just rewrite your Android code to use GET instead of POST and you should be all set.

Related Topic