In the case of an error, a standard format error response body will be returned and the HTTP status code will be set to an error status.
The response contains an object with a single error object with the following
keys:
code: This is the same as the HTTP status of the response.message: A short description of the error.status: A status code indicating the nature of the error.
For example, sending an invalid placeId parameter will return the following
error:
{
"error": {
"code": 400,
"message": "\"placeId\" value is malformed: \"aChIJqaknMTeuEmsRUYCD5Wd9ARM\"",
"status": "INVALID_ARGUMENT"
}
}
Possible errors include:
| Code | Status | Message | Troubleshooting |
|---|---|---|---|
| 400 | INVALID_ARGUMENT |
The key you provided is invalid. | Your API key is not valid or was not included in the request. Please ensure that you've included the entire key, and that you've enabled the API for this key. |
| 400 | INVALID_ARGUMENT |
"\"path\" parameter contains an invalid value: ☃" | Your request contained invalid arguments. The most likely causes of
this error are:
This error will not be returned if a |
| 403 | PERMISSION_DENIED |
Unregistered request was blocked. Please sign up using Google Developers Console. | Your API key is not valid or was not included in the request. Please ensure that you've included the entire key, and that you've enabled the API for this key. |
| 404 | NOT_FOUND |
HTTPS is required for this service. | Ensure that you are sending requests to
https://roads.googleapis.com/ and not
http://roads.googleapis.com/. |
| 429 | RESOURCE_EXHAUSTED |
The request was throttled due to project QPS limit being reached. | You've exceeded the requests per second per user limit that you configured in the Developers Console. This limit should be configured to prevent a single or small group of users from exhausting your daily quota, while still allowing reasonable access to all users. |
| 429 | RESOURCE_EXHAUSTED |
The request was throttled due to daily limit being reached. | You've exceeded the daily quota for your project. |
Exponential backoff
When requests fail, you should ensure that you retry requests with exponential backoff. For example, if a request fails once, retry after a second, if it fails again, retry after two seconds, then four seconds, and so on. This ensures that broken requests or wide scale failures do not flood Google’s servers, as many clients try to retry requests very quickly.
