REST API Specification – Response

All API functions return data in the following format (after response if decoded):

$response = array(
    'status' => '',
    'data' => array(),
    'message' => '',
    'errors' => array()

status is a string and its values can be ‘SUCCESS’ or ‘FAILURE’. This value can be used in the code to determine if the API call succeeded or failed.

data is an array of data. It can display in one of two ways:

1. With requests that return one item/model, data is a simple array of item/model properties, for example:

$data = array(
    'name'=>'ABC Ins.'

2. In the scenario where you search model/items, the format of data element is as follows:

$data = array(
            'name'=>'ABC Ins.'
            'name'=>'CBA Ins.'

message is a string that contains a response message.

errors is an array of errors that is displayed if the API call failed. For example if you are trying to create a new contact without providing all required data, you will get array of required fields.

Leave a Comment

  • spydon

    We are trying to create a new note by sending this JSON:

    {“data”:{“description”:”BAJSKAKA”,”occurredOnDateTime”:”2013-10-23 04:56:46″,”owner”:{“id”:1,”username”:”super”}}}

    With the following headers:

    ZURMO-SESSION-ID: d1b37367b9fa1c910d0b191b57a22e96
    ZURMO-TOKEN: 931e4ecc20e513ad0a5b3207845718eb
    Accept: application/json

    But we always get:
    {“status”:”FAILURE”,”data”:null,”message”:”Please provide data.”,”errors”:null}
    no matter what we send as data.
    We have sniffed our packages and the data is sent.

    Why do we not get an answer with an array of required fields like you state here? Or a success message?

  • Lev Sivashov

    Is errors a simple array of strings ?