0

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.

Community
  • 1
  • 1
Ian M
  • 13
  • 4

1 Answers1

0

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}&"
Sabuj Hassan
  • 38,281
  • 14
  • 75
  • 85
  • I changed Snoopy from a post to a get. Here is the resultand command it executes: /usr/bin/curl -k -D "/tmp/snoSmiNbI" -H "User-Agent: Snoopy v1.2.4" -H "Host: maps.googleapis.com:443" -H "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*" "https://maps.googleapis.com/maps/api/geocode/json\?address={encoded address}\&sensor=false\&key={apikey}" The \ escaping is from escapeshellcmd() which is highly recommended and built into snoopy, but it looks like it's getting re-encoded and passed on to google. The requested URL /maps/api/geocode/json%5C?address=... cannot be found – Ian M Apr 10 '14 at 16:52
  • Remove `\ ` from the `\?` and `\&` in your url. – Sabuj Hassan Apr 10 '14 at 16:55
  • I can't remove it. It's from the escapeshellcmd() and that is a must for security. However, it seems to be a snoopy bug that it wraps the command in quotes, and the wrapping caused the extra escaping. I removed the quoting around the escapeshellcmd and we're good to go. So a combination of a Snoopy bug and a GET vs POST. – Ian M Apr 10 '14 at 17:16
  • Hm... Then its a problem. Another solution if its possible to do String replace, then just do a String replace after the `escapeshellcmd` operation. – Sabuj Hassan Apr 10 '14 at 17:18