Error handling
This page contains a short overview of error handling when using the Zenegy API.
Error codes
Error handling in Zenegy API(s) can be separated into two main groups: the legacy error handling implemented in the Payroll API and the new error handling implemented in all other API(s).
Error handling
All responses, including error responses, are wrapped in a result object. The error information is returned with an HTTP code and error text in case of an error.
Result object example:
{
"isEmpty": true,
"value": {},
"isFailure": true,
"isSuccess": true,
"isNotFound": true,
"message": "string",
"resultType": "InternalError",
"httpStatusCode": "Continue"
}
If the action is a success, "isSuccess" is set to true, and "failure" is set to false.
If an action has failed, "isFailure" is set to true and "isSuccess" is set to false, and the message is set with a description of the error.
List of possible result types:
- InternalError = 0
- Ok = 1
- NotFound = 2
- Forbidden = 3
- Conflicted = 4
- Invalid = 5
- Unauthorized = 6
The HTTP status code corresponds to the information returned. See list below
Legacy error handling
Legacy error handling utilizes HTTP response codes to return error information from the API.
Information is enriched with extra text explanations of the error.
Currently, Payroll is using the legacy error codes.
The following error codes are returned from the API.
- 400 BadRequest - Provided information is invalid
- 401 Unauthorized - Invalid or no token provided
- 403 Forbidden - The user is not allowed to access the required resource
- 404 NotFound - Required resource is not found
- 406 NotAcceptable - Provided data is valid and cannot be accepted due to business rules
- 409 Conflict - Resource with the same id already exists
- 412 PreconditionFailed - Resource is not in a valid state or subscription is missing
- 500 InternalServerError - Unexpected error on the server side
Updated 7 months ago
Either read about our webhooks or jump right into one of our APIs