HTTP Verbs and Error Codes (legacy)
HTTP Verbs
Where possible, our API uses these HTTP verbs for each action:
Verb | Description |
---|---|
GET | Retrieve resources. |
POST | Create resources or other types of content submission. |
PUT | Update resources. Note: some types of resources can't be updated. |
DELETE | Delete resources. A successful delete returns a 200 or 204 response, and no body is included. |
Success Codes
If your request is successful, you receive one of the following status codes:
-
200 OK
Success (for example, resource was updated or retrieved). Note: a body isn't always returned. -
201 Created
A new resource has been successfully created (a Thng, collection, and so on). TheLocation
header contains the URL of the resource. The response body contains the new resource created. -
202 Accepted
The request was accepted and will be fulfilled asynchronously. Usually, the resource can be polled for completion status. -
204 No Content
The request was successful, but there are no results to return. An example of this is aDELETE
operation.
Error Codes
When calling our API, you might get an error code, which you must handle within your application. Errors can happen because your API request didn't follow our rules, or because our services are having a temporary problem.
-
400 Bad Request
If you send an incorrect JSON document (for example, a "}" is missing), or if the syntax/content is incorrect. -
401 Unauthorized
The access credentials (in theAuthorization
header) are missing or invalid. -
403 Forbidden
The credentials you provided are valid, but you aren't authorized to access the resource you're looking for. -
404 Not found
Returned when the request is valid, but the resource you tried to access doesn't exist, or is outside your scope. -
405 Method Not Allowed
The verb/method you used in the request isn't supported for this resource. -
415 Unsupported Media Type
Returned when the format you requested (for example, XML) isn't supported for this resource. Note: We support onlyapplication/json
as the content type. -
500 Internal Server Error
An error has occurred on the EVRYTHNG server. If you see this error, contact us and include details of the request you tried and the response you received. -
503 Service Unavailable
This error is usually returned when an external service that needed to fulfill your request didn't reply. -
504 Gateway Timeout
A service required to fulfill the request wasn't available.
Error Messages
Errors return a response body in JSON format with one or more error messages to help you understand what went wrong. Below is an example of such an error response:
HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
"status": 401,
"errors": [
"Access denied, please check your credentials!"
],
"code": 33619968,
"moreInfo": "https://developers.evrythng.com/docs/authentication"
}
All error objects have status
and errors
properties, which help your HTTP client handle the problem appropriately. A code
field might also be included to let you know what's wrong with the request.
These are some of the possible error codes:
Error Code | Description |
---|---|
INVALID_ID | The format of a resource identifier is incorrect. |
INVALID_CONTENT | A required field or parameter for the resource hasn't been set. |
INVALID_STATE | The state of a resource doesn't allow fulfilling a request. |
MISSING_RESOURCE | A resource doesn't exist. |
ALREADY_EXISTS | Another resource has the same value for this field, which can happen when the field is used as a unique key (for example, the email address of a user). |
ACCESS_FORBIDDEN | A resource doesn't allow access with the provided credentials. |
METHOD_FORBIDDEN | A resource doesn't allow using the verb with the provided credentials (for example, when the user has limited permissions to read content (GET )). |
Updated almost 2 years ago