Search code examples
curlgoogle-maps-api-3snoopy

snoopy/curl issue with google maps api


This is related to debugging a google maps api query error

We are using snoopy to do the request and it returns the "sensor must be true or false" problem.

The snoopy generated request is:

/usr/bin/curl -k -D "/tmp/snodlRoAD" -H "User-Agent: Snoopy v1.2.4" -H "Host: maps.googleapis.com:443" -H "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, /" -H "Content-type: application/x-www-form-urlencoded" -H "Content-length: 122" -d "address={encoded address}&sensor=false&key={apikey}&" "https://maps.googleapis.com/maps/api/geocode/json"

If I manually request [as per the known issues]

curl "https://maps.googleapis.com/maps/api/geocode/json?address={encoded address}&sensor=false&key={apikey}&"

it works.

But what is the fix for the snoopy generated command line. I have access to the source code to fix the issue if I can get the snoopy formatted request working.

I've posted to the Snoopy group as well but it doesn't seem very active.


Solution

  • In the snoopy generated curl, it is doing http POST operation(for using -d param). Whereas in your working curl command, you are using http GET. That's why one is working for you, and other one is not.

    Sine you have access to the source code, so remove the -d param from the command. And append the value of -d at the end of the url after ? mark. Just like your working one.

    "https://maps.googleapis.com/maps/api/geocode/json?address={encoded address}&sensor=false&key={apikey}&"