Return codes
The HTTP response code is contained
- in the HTTP header,
- in the content of the response in the case of an error.
The return codes are based on the HTTP return codes:
- 2XX - The call to the API unfolded correctly
- 4XX – The call to the API has an error in its parameters.
Codes with success:
- 200 OK: everything went well
- 201 Created: Resource created
- 204 No Content: Resource updated or deleted
The error codes that you are likely to see are the following:
- 304 Not Modified: Error during updating or deleting (the resource is not modified)
- 400 Bad Request: Missing or incorrect parameter
- 401 Unauthorized: Authentication failed
- 403 Forbidden: Access to the requested location is prohibited
- 404 Not Found: Unknown method or method not indicated
- 405 Method Not Allowed: You are not authorized to use the method that you are requesting
- 414 Request-URI Too Long: Your request is too large, please shorten it
- 417 Expectation Failed: The required parameters are either missing or are incorrect
- 500 Internal Server Error: Unidentified error
For example, if the authentication token is no longer valid for the following request:
curl -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbG...ccOqbVow8xOQyQ" https://api.messengeo.net/rest/resource |
The header of the HTTP response will be
HTTP/1.1 401 Unauthorized Date: Fri, 06 Mar 2015 21:32:06 GMT Server: Apache/2.2.16 (Debian) X-Powered-By: PHP/5.3.3-7+squeeze15 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Length: 46 Content-Type: application/json |
while the body of the HTTP response will be
{ "status": 401, "message": "Authenticate failed" } |