HTTP Status Codes
In addition to HTTP methods, HTTP status codes of the response are particularly important, as they are used to identify the success or failure of an operation.
The Five Main Categories of Status Codes
The five main categories of status codes, identified by the first digit of the code, are:
1xx: Informational
The server informs the client that the request has been received and the process is ongoing.
2xx: Success
The operation was completed successfully. The server has received, processed, and accepted the client's input, and the user typically sees the requested web page or resource.
3xx: Redirection
The server receives the request, but further actions and steps are needed on the client side to complete it correctly, as there are forwards and redirects.
4xx: Client Error
This is the first category of errors: the request cannot be completed due to client-side issues, such as incorrect syntax or a removed page. The user sees an automatic HTML page indicating the error.
5xx: Server Error
This type of code indicates server-side problems that prevent the successful completion of an apparently valid request. The server error can be temporary or permanent, and the user also receives an HTML page indicating the issue.
TeamSystem Enterprise WebAPI Status Codes
The codes managed in standard operations in TSEnterprise WebAPI are:
200: Success
Operation successful; this is the standard and most common response in the case of a correctly performed operation
201: Created
Resource created; used in the POST method for creating a NEW resource
202: Accepted
Request accepted; used, for example, when a work job has been successfully scheduled
400: Bad Request
Operation failed; this is the standard and most common response in the case of errors during the execution of
the operation
401: Unauthorized
Used exclusively in case of authentication errors
403: Forbidden
In case of permission/authorization errors (unsatisfied claims)
404: Not found
If resource is not found (e.g., a GET on a resource specifying a non-existent id)
405: Method Not Allowed
In case of unsupported HTTP methods (e.g., a PUT on a resource that only supports read operations)
409: Conflict
mainly used in two cases:
- to indicate the failure of a “Create,” “Update,” or “Delete” operation due to business logic (e.g., entity validation errors or business warnings)
- to indicate an INVALID resource in the “Validate” and “ValidateProperties” operations
500: Internal Server Error
In case of unhandled errors during the execution of the request