Google Maps API returns "Invalid Request" in a valid request

Asked
Active3 hr before
Viewed126 times

5 Answers

google
90%

Meta Stack Overflow , Stack Overflow Public questions & answers , Stack Overflow help chat ,Thanks for contributing an answer to Stack Overflow!

Use rawurlencode for this :

$inhalt = simplexml_load_file('http://maps.googleapis.com/maps/api/geocode/xml?'.
   'address='.rawurlencode($strasse).
   ',+'.rawurlencode($plz).
   '&sensor=true');
88%

How about this code? I created the code based on your code. I tried my iPad and that worked.,It really is a matter of direction of indices in your polygons, while one is clockwise other should be counter-clockwise. Change your second array to:,i am trying to reverse geocode a bunch of addresses for my database. I have about 200 addresses, and half of them worked like a charm.. i did put the google maps request in a loop and it worked. There were about 100 adresses that returned a "INVALID REQUEST" message. I echoed the request url and put it in my browser and it returned a "Status: OK" and all the data. Why does my script return a invalid request and another browser-tab returns OK?,https://developers.google.com/my-business/content/review-data#list_all_reviews

Thats the function i used:

function getLatLon($strasse, $plz) {
   $inhalt = simplexml_load_file('http://maps.googleapis.com/maps/api/geocode/xml?address='.$strasse.
      ',+'.$plz.
      '&sensor=true');

   $geo['lat'] = $inhalt - > result - > geometry - > location - > lat;
   $geo['lon'] = $inhalt - > result - > geometry - > location - > lng;

   return $geo;
}
load more v
72%

I'm using the latest version available via pip and have problems with retrieving details about a place. This is the result for places:,Successfully merging a pull request may close this issue., No suggested jump to results , Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

{'formatted_address': 'Welserstraße 4, 90489 Nürnberg, Germany',
 'geometry': {'location': {'lat': 49.4611013, 'lng': 11.105897},
  'viewport': {'northeast': {'lat': 49.46240978029149,
    'lng': 11.1071261802915},
   'southwest': {'lat': 49.4597118197085, 'lng': 11.1044282197085}}},
 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png',
 'id': '7f1d1322ae01fbe1433d70be84d25080cb72b4ef',
 'name': "Sanny's Hundeservice - Hundebetreuung und Hundetraining in Nürnberg",
 'opening_hours': {'open_now': True, 'weekday_text': []},
 'photos': [{'height': 2448,
   'html_attributions': ['<a href="https://maps.google.com/maps/contrib/110315020868274071831/photos">Sanny&#39;s Hundeservice - Hundebetreuung und Hundetraining in Nürnberg</a>'],
   'photo_reference': 'CmRaAAAAJ-qzyAU24Jj2zVRBHkzvpUnSFGAptiHMVJahSHDzprFRQUuGOot9iJVqNaZR6j6bijUIg7cETJCXAOUfT-ePCu-LYMbFjCFfS-dgrRQW6VWCAGlSBid8bCh-3Jmb5cKrEhBZi8eT76b9z77xzyrwvY8BGhTd5oY9iuRY4O4Y2CVAjEdcDDJ1dw',
   'width': 3264}],
 'place_id': 'ChIJXZcoZ5JXn0cR7x6kK3ycshs',
 'rating': 4.3,
 'reference': 'CmRRAAAAkSPGEzAUejFi-lkdSyMoHjBF60rVYpMzEQO5-uhshxZolK_pmIW_dhlL0xmW7Xqse71AUMdpkPjSKal931o8E-hP7DlvGFMoumQ7k9_KZRSWghoAgjgvy23c5TKuFhHTEhBPQQ6A6ooBCyco26mhxrjmGhRqeqV-lGuTXtv3Mmm9yMixMjjQkg',
 'types': ['point_of_interest', 'establishment']}
load more v
65%

Invalid Request Format Error,Troubleshoot a REST API,Publish Your Mobile Android Application to the Google Play Store, Invalid Response Format Error

The Invalid Request Format error is issued in the following situation:

Invalid Request Format
load more v
75%

Using the OpenCage geocoding API requires a valid API key that you must pass with each HTTP request to the API as the value of the key parameter (one of two required parameters). , The OpenCage geocoding API uses a rate limiting mechanism to ensure that the service stays available to all users. , sensor - required by Google as an indicator of whether the request comes from a device with a location sensor; this parameter is ignored by the OpenCage geocoding API. ,A geocoder API request is in the following form:

"rate": {
   "limit": 2500,
   "remaining": 2498,
   "reset": 1605312000
},
load more v

Other "google-undefined" queries related to "Google Maps API returns "Invalid Request" in a valid request"