Error Codes
API requests that result in errors will return an appropriate HTTP status code to help you identify the type of error. You can use the table below to understand what each code means.
HTTP Status Code | Text | Description |
---|---|---|
400 | Validation Error | The request body/query string is not in the correct format. For example, the GetUserDetails API requires the user_id field to be sent as part of the request and if it is missing, this status code is returned. |
401 | Authentication Failure | Indicates that the Authorization header is either missing or incorrect. |
403 | Access Denied | This indicates that the user whose credentials were used in making this request was not authorized to perform this API call. |
404 | Requested Resource not Found | This status code is returned when the request contains invalid ID. For example, an API call to retrieve a user with an invalid ID will return a HTTP 404 status code to let you know that no such user exists. |
405 | Method not allowed | This API request used the wrong HTTP verb/method. For example an API PUT request on /api/users endpoint will return a HTTP 405 as /api/users allows only GET and POST requests. |
406 | Unsupported Accept Header | Only application/json and / are supported. When uploading files multipart/form-data is supported. |
409 | Inconsistent/Conflicting State | The resource that is being created/updated is in an inconsistent or conflicting state. For example, if you attempt to Create a User with an ID number that is already associated with an existing user, this code will be returned. |
415 | Unsupported Content-type | Content type application/xml is not supported. Only application/json is supported. |
429 | Rate Limit Exceeded | The API rate limit allotted for your Edunation account has been exhausted. |
500 | Unexpected Server Error | Phew!! You can't do anything more here. This indicates an error at Edunation’s side. Please email us your API script along with the response headers. We will reach you out to you and fix this ASAP. |
Error Codes
In addition to the the error message, the error response will also contain a error code that is machine-parseable. The following table lists the error codes and their descriptions.
Code | Description |
---|---|
missing_field | A mandatory attribute is missing. For example, calling Create a User without the mandatory first name field in the request will result in this error. |
invalid_value | This code indicates that a request contained an incorrect or blank value, or was in an invalid format. |
duplicate_value | Indicates that this value already exists. This error is applicable to fields that require unique values such as the ID number in a user. |
datatype_mismatch | Indicates that the field value doesn't match the expected data type. Entering text in a numerical field would trigger this error. |
invalid_field | An unexpected field was part of the request. If any additional field is included in the request payload (other than what is specified in the API documentation), this error will occur. |
invalid_json | Request parameter is not a valid JSON. We recommend that you validate the JSON payload with a JSON validator before firing the API request. |
invalid_credentials | Incorrect or missing API credentials. As the name suggests, it indicates that the API request was made with invalid credentials. Forgetting to apply Client Secret or Access Token is a common cause of this error. |
access_denied | Insufficient privileges to perform this action. An user attempting to access admin APIs will result in this error. |
account_blocked | Account has been blocked or cancelled. |
ssl_required | HTTPS is required in the API URL. |
readonly_field | Read only field cannot be altered. |
password_lockout | The user has reached the maximum number of failed login attempts. |
no_content_required | No JSON data required. |
inaccessible_field | The user is not authorized to update this field. |
Error Response
In addition to the HTTP status code, most errors will also return a response body that contains more information to help you debug the error. A sample error response is shown below. The format of the error response body is explained after the example.
{
"Message": "You are not authorized to perform this action",
"ErrorCode": "not_authorized",
"Success": false,
"StatusCode": 401
}
Updated almost 3 years ago