HTTP Status Codes

When an API request results to an error, BACE sends a response with the error details in the body and a corresponding HTTP status code. The response body contains a description of the error and possible causes.

BACE sends the following HTTP status codes in the header:

  • 2xx - The request is successful.

  • 4xx - The request failed because of the information in the request, such as values with incorrect format, or not having the required fields.

  • 5xx - The request failed because of errors with BACE's servers.

Error Response fields

Example

Here's an example of an error response for a request that uses non existing record id.

{
  "name": "Not Found",
  "message": "The requested record with id 8f14e83c-10a0-46a4-9028-c56916162b7c could not be found or is inaccessible",
  "code": 0,
  "status": 404,
  "type": "yii\\web\\NotFoundHttpException"
}

Troubleshooting requests

Bad Request - 400

Cause

BACE APIs return this error when:

  • The request is malformed or is not in the expected format.

Solution

Check the syntax and format of your request.

Unauthorized - 401

Cause

BACE APIs return this error when:

  • You are trying to access API endpoint, but Authorization header is missing in request or API token is not valid.

  • Your account lacks the permission to access an endpoint.

Solution

Make sure that the request is using an existing and valid API token. We show all endpoints that you may have access to in the documentation and it is up to your implementation to handle this response gracefully.

If you feel that an endpoint may be of use to you, but you receive an unauthorized response in your application, you may contact us to request additional permissions for your account(s).

Example:

{
    "name": "Unauthorized",
    "message": "Your request was made with invalid credentials.",
    "code": 0,
    "status": 401,
    "type": "yii\\web\\UnauthorizedHttpException"
}

Not Found - 404

Cause

BACE APIs return this error when:

  • A request is trying to perform an operation on a resource that does not exist.

  • A POST request contains a resource ID that does not exist.

Solution

Make sure that the request is using an existing resource ID. Make sure you are using correct route, and you do not have typo in your URL.

Last updated