API Error Handling

For the API we want to create a more detailed error model. The error message should be machine- and human-readable, therefore we use json format as response language.

One example could be:

{
  instance: "http://127.0.0.1:5000/api/0.1/entity/157",
  title: "Forbidden",
  status: 403,
  detail: "You don't have the permission to access the requested resource. Please authenticate with the server, either through login via the user interface or token based authentication.",
  help: "https://redmine.craws.net/projects/uni/wiki/API_Authentication",
  timestamp: "Fri, 29 May 2020 10:13:22 GMT",
}

As a RFC draft for API error messages states (https://tools.ietf.org/html/draft-nottingham-http-problem-07):

Used Error Codes

Following error codes will be caught by the API error handler:

Code Description Detail Error Message
400 Bad Request Client sent an invalid request — such as lacking required request body or parameter The request is invalid. The body or parameters are wrong.
401 Unauthorized Client failed to authenticate with the server You failed to authenticate with the server.
403 Forbidden Client authenticated but does not have permission to access the requested resource You don't have the permission to access the requested resource. Please authenticate with the server, either through login via the user interface or token based authentication.
404 Not Found The requested resource does not exist Something went wrong! Maybe only digits are allowed. Please check the URL.
404a Not Found The requested resource does not exist The requested entity doesn't exist. Try another ID.
404b Not Found The requested resource does not exist The syntax is incorrect. Only digits are allowed. For further usage, please confer the help page.
404c Not Found The requested resource does not exist The syntax is incorrect. Valid codes are: actor, event, place, source, reference and object. For further usage, please confer the help page.
404d Not Found The requested resource does not exist The syntax is incorrect. These class code is not supported. For the classes please confer the model.
404e Not Found The requested resource does not exist The syntax is incorrect. Only integers between 1 and 100 are allowed.
404f Not Found The requested resource does not exist The syntax is incorrect. Only valid operators are allowed.
405 Invalid Method The method is not available The method used is not supported. Right now only GET is allowed.

Reference Links

To Do: