Error codes

Error handling in Zenegy API(s) can be separated into two main groups one is the legacy error handling implemented in the payroll DK api and the new error handling implemented in all other API(s).

Error handling

All responses including error responses are wrapped in result object. In case of error the error information is returned with http code and error text.

Result object example:

Copy
Copied
{
  "isEmpty": true,
  "value": {},
  "isFailure": true,
  "isSuccess": true,
  "isNotFound": true,
  "message": "string",
  "resultType": "InternalError",
  "httpStatusCode": "Continue"
}

If action is success isSuccess is set to true and isFailure is set to false. If action has failed isFailure is set to true and isSuccess is set to false and message is set with description of the error

List of possible result types:

  • InternalError = 0
  • Ok = 1
  • NotFound = 2
  • Forbidden = 3
  • Conflicted = 4
  • Invalid = 5
  • Unauthorized = 6

Http status code corresponding to the information returned. See list bellow

Legacy error handling

Legacy error handling utilizes http response codes to return error information from the API. Information is enriched with extra text explanation of the error. Currently payroll Denmark and Switzerland are using the legacy error codes.

The following error codes are returned form the API.

  • 400 BadRequest - Provided information is invalid
  • 401 Unauthorized - Invalid or no token provided
  • 403 Forbidden - User is not allowed to access the required resource
  • 404 NotFound - Required resource is not found
  • 406 NotAcceptable - Provided data is valid cannot be accepted due to business rules
  • 409 Conflict - Resource with the same id already exists
  • 412 PreconditionFailed - Resource is not in valid state or subscription is missing
  • 500 InternalServerError - Unexpected error on the server side