📨Responses

The API returns HTTP responses on each request to indicate the success or otherwise of API requests. The codes listed below are often used, and the API may use others.

Response codes

Successful API responses will have a 2xx HTTP status code.

Note that 4xx and 5xx responses may be returned for any request and clients should cater for them.

Validation

Methods that take input will validate all parameters. Any parameter that fails validation will trigger an error response with status HTTP 422. The response body will be a JSON object that includes a message as well as a list of fields that failed validation.

{
  "Message": "Validation Failed",
  "Errors": [
    {
      "Message": "This is a model-wide error"
    },
    {
      "Field": "Url",
      "Message": "'Url' should not be empty."
    }
  ]
}

Pagination

Some list resources in the API are paginated by default to allow clients to traverse data over multiple requests. Their responses may contain a Pagesobject that contains pagination links a client can use to traverse the data without having to construct a query. The link relations for thePagesfield are as follows

Pagination

Pagination page out of bounds: return 200 status code - with empty array as data. In addition, you should provide hyperlinks to point clients to "correct" pages, for example the first page or the last "valid" page.

{
  "Pages": {
    "First": "href": "http://example.org/api/user",
    "Prev": "href": "http://example.org/api/user?page=2",
    "Next": "href": "http://example.org/api/user?page=4",
    "Last": "href": "http://example.org/api/user?page=133"
  },
  "PerPage": 50,
  "Page": 1,
  "Count": 100,
  "Results": [
    {
      "Param1": "test1",
      "Param2": "test2",
    },
    {
      "Param1": "test1",
      "Param2": "test2",
    }
  ]
}

Last updated