Error Responses

When an API request is successful, the API returns a 200 OK status code along with the requested data in the response body. If an error occurs, the API returns one of the canonical error codes defined by Google APIs, mapped to an HTTP status code, and a response body containing error information. When encountering an error, inspect the message and status fields in the JSON response body for specific details to help with debugging.

Error format

If a request results in an error, the API returns an appropriate HTTP status code and a JSON response body. The error response contains an error object with the following structure:

  { 
  
 "error" 
 : 
  
 { 
  
 "code" 
 : 
  
 403 
 , 
  
 "message" 
 : 
  
 "User does not have sufficient permissions for this property." 
 , 
  
 "status" 
 : 
  
 "PERMISSION_DENIED" 
  
 } 
 } 
 

The error object contains these fields:

Field Description
code The HTTP status code, such as 400, 401, 403, 429, or 500.
message A short description of the error.
status The canonical error code, such as INVALID_ARGUMENT , UNAUTHENTICATED , PERMISSION_DENIED , RESOURCE_EXHAUSTED , or INTERNAL .

Common errors

The following table lists common errors returned by the API.

HTTP Status Code Canonical Code Reason Description
400
INVALID_ARGUMENT Bad Request The request is malformed. This can be caused by missing or invalid parameters, such as an incorrect date range or a malformed filter.
401
UNAUTHENTICATED Invalid Credentials The request does not have valid authentication credentials for the target resource. This can happen if the OAuth 2.0 access token is missing, invalid, or expired. Follow instructions in Authenticating with OAuth 2.0 to obtain a valid token.
403
PERMISSION_DENIED Insufficient Permissions The authenticated user does not have access to the requested Google Analytics property.
429
RESOURCE_EXHAUSTED Quota Exceeded The request was denied due to API quota limits being reached. See Data API limits and quotas for more information. You may be exceeding per-project or per-property limits.
500
INTERNAL Internal Server Error An unexpected server error occurred. This is usually a temporary issue. Retrying the request with exponential backoff is recommended. To avoid exceeding server error quotas , it is important to implement exponential backoff with retry limits .
503
UNAVAILABLE Service Unavailable The service is temporarily unavailable. This is usually a temporary issue. Retrying the request with exponential backoff is recommended. To avoid exceeding server error quotas , it is important to implement exponential backoff with retry limits .
Design a Mobile Site
View Site in Mobile | Classic
Share by: