Response Codes


Opereto API mainly makes a use of the following standard HTTP codes:


Code Description
200/201/202 Successful operations (depends on the context).
400 Bad Request: mainly used in cases of invalid or missing input
403 Forbidden: whenever user is not allowed to perform a given operation
404 Not Found: requested entities are not found in the system.
405 Method Not Allowed: for instance, trying to use PUT where only POST/GET are allowed.
409 Conflict: for instance, trying to create an entity that is already exists.
500 Internal Server Error: usually indicates a general exception. In such cases, looking at the server log for more details is recommended.
501 Not Implemented: indicates that while the url is valid, the specific operation is currently not supported.


Response Structure


Key Optional Description
status NO "success" for successful operations, "fail" for failed operations and "error" if server failed to process the request.
data YES contains all data returned from the server for a given operation. If not data is returned, the response json will not include this key.
message YES contains messages that delivered by the server to the client. Mainly used to hold the error messages in case of failed operations.


Example 1successful operation, no data returned

{
    "status": "success",
}

 

Example 2: successful operation with data

{
  "status": "success",
  "data": {
    "active": true,
    "modified_date": "2015-10-31T18:48:08.309566",
    "id": "my_agent",
    "online": false
  }
}

 

Example 3: failed operation 

{
  "status": "fail",
  "message": "Agents may be deleted only if not connected. Please shutdown the relevant agents prior to deletion."
}