UWAGA: poniższa dokumentacja dotyczy nieakutalnej wersji API (2.0.0). Kliknij aby przejść do aktualnej dokumentacji.

<<

Errors

This document contains a list of errors that the API methods can return.

Errors can be divided into six categories:

system

Fatal system errors, these should not appear during normal API operations.

request_format

The request you sent had incorrect format. This means that you failed to conform to the request format described in README, for example didn't specify the module that you want to use. These errors do not include method input validation (data is not checked here)

version

These errors indicate problems with API version. See Versions for more information.

auth

Problems with authentication. The most common is incorrect login or password or expired session.

data_format

The method input (the data element of the request) is incorrect for the method. It includes only the formal validation that could be as well performed by the API client based on the documentation and specification (JSON/WSDL). For example, it includes checking that a service id is an unsigned integer, but not that this service is accessible by the user.

data_validation

Any errors that cannot be predicted before calling the method. Examples include trying to access inexistent objects or dynamic validations based on other object types (a good example is the service features array - validations are dependent on the service type).

Error format

The error data will be returned in the response's error field when using JSON or in SOAP Fault's details when using SOAP. Error data contains three fields:

An example

Assume that we want to create a http service but our package does not allow checks every 10 minutes and we have reached the services limit and we don't have group with id 123:

        {
                "module":"Service",
                "method":"Create",
                "auth":{"login":"monit_api_test_user","password":"my_passwoRd"},
                "data":{
                        "name":"a new service",
                        "interval":600,
                        "type_id":1,
                        "url":"monit24.pl",
                        "group_id":123  
                }
        }

The API will complain:

        {
                "auth":{},
                "version":"2.0.0",
                "error":{
                        "blame":[
                                {
                                        "path":"data/group_id",
                                        "message":"Group not found",
                                        "code":1000201
                                },
                                {
                                        "path":"data",
                                        "message":"Services limit for your account has been reached",
                                        "code":1000104
                                },
                                {
                                        "path":"data/interval",
                                        "message":"Too low interval. Your account limits allow you to check services not more frequently than every 900 seconds",
                                        "code":1000106
                                }
                        ],
                        "type":"data_validation",
                        "message":"Input data validation error"
                },
                "data":null
        }

Note that sometimes some blames can be dependent on others. For example, service features will not be validated if you specify an inexistent type for your service, because the features are type-dependent - API will return an error before even trying any features validation.

An example that shows the path attribute for arrays - trying to modify the port service feature (it has to be an integer):

        {
                "module":"Service",
                "method":"Update",
                "auth":{"login":"monit_api_test_user","password":"my_passwoRd"},
                "data":{
                        "id":278174,
                        "features":[
                                {
                                        "id":"port",
                                        "value":"this_is_not_a_number"
                                }
                        ]
                }
        }

The response:

        {
                "auth":{},
                "version":"2.0.0",
                "error":{
                        "blame":[
                                {
                                        "path":"data/features/0/value",
                                        "message":"Incorrect value: integer required",
                                        "code":1000105
                                }
                        ],
                        "type":"data_validation",
                        "message":"Input data validation error"
                },
                "data":null
        }

<<