2.1.3 Responses to Requests

A response to a request always includes JSON data in the following format:

{
    "data": {
        "success": true,
        "array": [
            {
                "serial_number": "54-0562-0293"
            }
        ]
    }
}

Make sure that the cover-all data container and the nested boolean success are always included. Success is always true if the command has been (or is expected to have been) executed successfully. Nevertheless, it cannot be guaranteed for the time being that the success=true value really means success for all commands. For example, there may be no information on successful execution of the commands that 2N® IP Mobile resends to the 2N IP intercoms and so the value cannot be reported. Such commands include the PUT method and the commands that do not return values: calls, opening doors, etc. Thus, the user has to use another request (call/status, e.g.) to know the command's success.

The false value is returned for many reasons. At present, the HTTP API cannot distinguish errors and specific error messages will be implemented in the next versions if necessary. The short list of potential errors is as follows:

  • Request entering error – invalid argument values, missing arguments, non-existent subsystem, wrong JSON data format, incorrect HTTP method, etc.
  • A 2N® IP Mobile command is entered but the application is not running. Therefore, make sure that the application has been started before sending a 2N® IP Mobile command.

The data container can include more items whose names and contents depend on the request to be sent. Our example includes an array of serial numbers.