HTTP status and error codes
Bigin APIs use standard HTTP response status codes and error descriptions when informing users/applications about the status and error of an API call. The HTTP status code in the response header separates the errors of the request, while the response body contains additional details providing information about the error codes.
Error and status codes
The HTTP status codes categorize the errors of the request and indicate whether the response server executes the request or not.
Bigin API categorizes the status codes into the following types:
- 2xx - This code returns when the request is successful.
- 3xx - This code returns when the client needs to take further action to serve their request.
- 4xx - This code returns when the request throws an error.
- 5xx - This code returns when there is an issue with the server.
The following table contains the possible status codes that return when you make an API request to Bigin:
Status Code | Title | HTTP Method | Description |
---|---|---|---|
200 | OK | GET/PUT/DELETE | This code is used when an entire response is successful. |
201 | Created | POST | This code is used when the requested API inserts a record. |
202 | Accepted | POST/PUT/DELETE | This code is used when the requested API inserts multiple records. |
204 | No Content | GET | This code is used when the resource does not exist. |
304 | Not Modified | PUT/GET | This code is used when there is no update in the requested resource since the last time you accessed it. |
400 | Invalid Data (or) Bad Request | GET/POST/PUT/DELETE | This code is used when the requested API or authentication is invalid or the given request data is invalid. |
401 | Unauthorized Error | GET/POST/PUT/DELETE | This code is used when the authentication tokens are invalid. |
401 | Unauthorized Error | GET/POST/PUT/DELETE | This code is used when the authentication tokens are invalid. |
403 | Forbidden | GET/POST/PUT/DELETE | This code is used when there is no permission for the requested resource. |
404 | Not Found | GET/POST/PUT/DELETE | This code is used when the requested resource is not found. |
405 | Method Not Allowed | PUT | This code is used when the requested method is not supported by the target resource. |
413 | Request Entity Too Large | POST/PUT | This code is used when a request has a file to upload and the size of the file is larger than the server is able to process. |
415 | Unsupported Media Type | POST/PUT | This code is used when the server does not support the media/file type the request is trying to upload. |
429 | Too Many Requests | GET/POST/PUT/DELETE | This code is used when the client exceeds the number of API calls in 24 hour period or the number of users for an app. |
500 | Internal Server Error | GET/POST/PUT/DELETE | This code is used when the server throws an internal error. |
Representation of error response
The error response can be viewed in two formats such as HTTP response and JSON response. The HTTP response contains the header details of the response such as HTTP status codes, metadata of the response, and so on. On the other hand, the JSON response contains details about the error in the human-readable format.
For example, the error format for HTTP status code 400 looks like this:
HTTP response
HTTP/1.1 400
Server: ZGS
Date: Mon, 12 Dec 2022 13:17:56 GMT
Content-Type: application/json;charset=UTF-8
Content-Length: 204
Connection: keep-alive
Set-Cookie: 3d223cf300=6cd7d9b17e6c6d0feaf53c99d1891ab5; Path=/
X-XSS-Protection: 1
X-Frame-Options: sameorigin
X-Content-Type-Options: nosniff
Set-Cookie: JSESSIONID=FC7042CB324F8FB882F9D0C21FCECD2A; Path=/; Secure; HttpOnly
Content-Language: en-US
JSON response
{
"code": "INVALID_REQUEST",
"details": {},
"message": "Unable to process your request. please verify whether you have entered proper method name, parameter and parameter values.",
"status": "error"
}
The JSON format of the error response contains the following details:
Name | Data type | Description |
---|---|---|
status | string | Indicates the state of the response object. Can be success or error. |
code | string | Indicates the error code such as INVALID_DATA, NO_PERMISSION, INVALID_MODULE and so on. |
message | string | Displays human-readable message that explains about the error to users. |
details | string | Additional information about the error. For example, when the NO_PERMISSION error occurs, this section includes permissions that are required to avoid this error. |
Also, Bigin APIs use the generic status codes for several different errors. In such cases, the error response in JSON format contains the machine-parsable code parameter that separates the failure of the requests and provides the respective error details. This allows you to understand the errors better and take necessary steps to avoid them.
The following table provides the information about API error codes and respective descriptions:
code | Description |
---|---|
INVALID_DATA | This error occurs when:
|
INVALID_MODULE | This error occurs when:
|
NO_PERMISSION | This error occurs when the client does not have permission to the following:
|
INVALID_REQUEST_METHOD | This error occurs when the request has an invalid HTTP method type. |
INVALID_URL_PATTERN | This error occurs when the specified request URL is invalid. |
OAUTH_SCOPE_MISMATCH | This error occurs when the request scope doesn't match the authorized scope. |
REQUIRED_PARAM_MISSING | This error occurs when the request doesn't have the mandatory parameter. |
MANDATORY_NOT_FOUND | This error occurs when the mandatory fields aren't specified in the input data of the request. |
DUPLICATE_DATA | This error occurs when the request adds the duplicate values for unique fields of a record. |
NOT_SUPPORTED | This error occurs when the requested APIs support just administrators. |
MEDIA_TYPE_NOT_SUPPORTED | This error occurs when the 'Content-Type' header isn't shared along with the request. |
INTERNAL_ERROR | This error occurs when the server raises an unexpected or unhandled exception. |
AUTHORIZATION_FAILED | This error occurs when the trial gets expired or when the client doesn't have sufficient privileges to the following:
|
INVALID_FILE_FORMAT | This error occurs when the request tries to upload the invalid file format. |
FILE_TOO_LARGE | This error occurs when the request tries to upload a file which is larger than the server is able to process. |
MANDATORY_FIELDS_NOT_MAPPED | This error occurs when all the mandatory fields in the module aren't mapped. |
INVALID_FIELD | This error occurs when the field API name is incorrect. |
INVALID_FORMAT | This error occurs when the specified field format is incorrect. |
INVALID_FILE_ID | This error occurs when the specified field ID is incorrect. |
HEADER_LIMIT_EXCEEDED | This error occurs when the number of fields mapped exceeds the maximum limit of 200. |
COLUMN_INDEX_NOT_FOUND | This error occurs when the column index maps with negative values. |
MODULE_NOT_AVAILABLE | This error occurs when the API name of a module is incorrect or the API request doesn't support the module. |
RESOURCE_NOT_FOUND | This error occurs when the requested resource isn't available. |
FILE_SIZE_MORE_THAN_ALLOWED_SIZE | This error occurs when the request tries to upload the image file which exceeds the allowed size of up to 1 MB and 10 MP. |
LICENSE_LIMIT_EXCEEDED | This error occurs when the request to add users exceeds the maximum number of allowed users in the subscribed Bigin plan. |
CANNOT_UPDATE_DELETED_USER | This error occurs when the request tries to update the deleted user. |
INVALID_REQUEST | This error occurs when the request tries to re-invite the confirmed user or deactivate the primary contact. |
EMAIL_UPDATE_NOT_ALLOWED | This error occurs when the request tries to update the email of the confirmed user. |
ID_ALREADY_DEACTIVATED | This error occurs when the request tries to deactivate the user who is already in deactivate state. |
ID_ALREADY_ACTIVE | This error occurs when the request tries to activate the user who is already in active. |
FEATURE_PERMISSION | This error occurs when the share among the subordinates feature isn't available for the Bigin account. |
ID_ALREADY_DELETED | This error occurs when the request tries to delete the user who is already removed from the account. |
PATTERN_NOT_MATCHED | This error occurs when the request has the incorrect parameter value. |
UNABLE_TO_PARSE_DATA_TYPE | This error occurs when the request body or parameter values are in the wrong format. |