Skip to main content

Errors

When interacting with the Emogg REST API, it's important to handle errors gracefully. The API uses conventional HTTP response codes to indicate the success or failure of requests. In case of an error, the API response will include a JSON object with detailed information to help diagnose and resolve the issue.

Response structure

The JSON error response contains the following fields:

FieldTypeDescription
errorboolSet to true to indicate that the response is an error.
statusnumberThe HTTP status code associated with the error.
messagestringA human-readable string describing the cause of the error.

Examples

{
"error": true,
"status": 404,
"message": "The requested resource was not found."
}

This example shows a 404 Not Found error response, where the message field provides a clear description of the issue.

Handling errors in your application

When your application encounters an error response from the API, it should:

  1. Check the status field to determine the type of error.
  2. Display the message to the user if appropriate, or log it for debugging purposes.
  3. Take corrective action based on the error type, such as ensure valid parameters are used for a 400 error or throttling requests for a 429 error.

Common HTTP status codes

Below is a table of the most common HTTP status codes returned by the Emogg REST API and their meanings:

CodeTitleDescription
200OKThe request has succeeded. The client can read the result of the request in the body.
201CreatedThe request has been fulfilled and resulted in a new resource being created.
204No ContentThe request has succeeded and there is no content to send for this request.
400Bad RequestThe server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax or insufficient funds).
401UnauthorizedThe request has not been proccessed because valid authentication credentials were not specified.
404Not FoundThe requested resource does not exist.
429Too Many RequestsThe user has sent too many requests in a given amount of time (see rate limiting).
500Internal Server ErrorSomething went wrong on Emogg's end. (These are rare.)
503Service UnavailableServer is down for maintenance or is overloaded.