1

I am recently trying to make an Android App, which uses Google Civic API to find the local officials based on the user input (a zip code). During testing, I found I randomly encounter Error 400: "Failed to parse address" when sending the query to API's endpoint.

I used the following format to do my query: https://www.googleapis.com/civicinfo/v2/representatives?key=MY_API_KEY&address=zip-code

And for example, if the zip code input is 90210, it will show the following error when I clicked the query address:

{ "error": { "code": 400, "message": "Failed to parse address", "errors": [ { "message": "Failed to parse address", "domain": "global", "reason": "parseError" } ] } }

Is anyone knows what happened and how to fix it?

Thanks in advance!

Allegro
  • 39
  • 1
  • 4

1 Answers1

0

Google has provided an example.

You can see in their example:

https://www.googleapis.com/civicinfo/v2/representatives?key=<YOUR_API_KEY>&address=1263%20Pacific%20Ave.%20Kansas%20City%20KS

It would still work even if the address has been shortened to:

https://www.googleapis.com/civicinfo/v2/representatives?key=<YOUR_API_KEY>&address=KS

If you provide the state along with the zip code, it will avoid the error.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Ryan W
  • 98
  • 2
  • 9