After a REST API call, a resource will return an HTTP Status Code.
Success
The following Response Codes are returned for successful resource calls:
- 200: OK
- Returned after GET, POST, PUT calls.
- Calls with Filters that find no data still return a 200: OK success. For example, if the URI to find a list using a List Name that does not exist (https://mysite/rest/lists?listName=mylistNotExists), data exists at the Resource level (lists), but the returned array is empty. Something exists at the URI, just not for the parameters requested.
- 204: No Content
- Returned after a DELETE call. Since the object was deleted, there is nothing to return and an empty response is expected. While a validation of which instance was deleted would be useful, this cannot always be returned. For example, deleting a List or Contact completely removes a row in the database (hard delete vs. soft delete), and the id of the instance no longer exists in the database to return.
Error
Error Response Codes include both Client Errors (4xx) and Server Errors (5xx). Client errors include those in which the resource call headers are invalid. Server errors generally indicate invalid data has been sent or requested.
Common Client Errors include:
- 400: Bad Request
- Values in the Header are improperly formed. Generally indicates the "Accept" header is incorrect.
- 401: Unauthorized
- The Basic Authorization header is invalid, the Realm Name or Password are incorrect, or the encoding is bad.
- 404: Not Found
- Resource call requested an instance that does not exist. For example, in a get List by ID call, the List ID cannot be found in the database.
- 405: Method Not Allowed
- Resource call is incorrectly formatted. For example, in a Get List by ID call, the List ID is missing.
- 406: Not Acceptable
- Values in the Header are improperly formatted or missing.
Common Server Errors include:
- 500: Internal Server Error
- Returned after GET, POST, PUT calls. The result set will generally include clarification as to the reason for the failure, such as:
{ "error": "A List Name should be defined. The List Name field must be at least 1 characters long" "status": "Internal Server Error" "statusCode": 500 }