Skip to main content
Skip table of contents

Add ОNVIF: Onvif.Add

The method and parameters

string Onvif.Add (CameraObject cameraID0, CameraObject cameraID1)

CameraObject cameraID0 REQUIRED – the camera identifier for which the ONVIF functionality will be added.

object CameraObject

string cameraID0.events.MotionAlarm = dvr|live|capture|publish – the list of handlers for the MotionAlarm event


string cameraID0.events.PowerAlarm = dvr|publish – the list of handlers for the PowerAlarm event.


string cameraID0.hostname = 192.168.204.25 – the camera address.


CameraObject cameraID1 REQUIRED – the camera identifier for which the ONVIF functionality will be added.

object CameraObject

stringcameraID1.events.MotionAlarm = dvr|live|capture|publish – the list of handlers for the MotionAlarm event.


stringcameraID1.events.PowerAlarm = dvr|publish– the list of handlers for the PowerAlarm event.


stringcameraID1.hostname = 192.168.204.26– the camera address.


POST /api/

JSON-RPC
JSON
{
    "jsonrpc": "2.0",
    "method": "Onvif.Add",
    "params": {
        "cameraID0": {
            "hostname": "192.168.204.25",
            "events": {
                "MotionAlarm": "dvr|live|capture|publish",
                "PowerAlarm": "dvr|publish"
            }
        },
        "cameraID1": {
            "hostname": "192.168.204.26",
            "events": {
                "MotionAlarm": "dvr|live|capture|publish",
                "PowerAlarm": "dvr|publish"
            }
        }
    },
    "id": 1
}
cURL
BASH
curl -k --request POST \
	--url 'https://your-domain/api/' \
	--header 'Content-Length: 520' \
	--header 'Content-Type: application/json' \
	--header 'Accept: application/json' \
	--header 'Authorization: Bearer <api-authorization-token>' \
	--header 'Content-Length: <data length>' \
	--data '{
    "jsonrpc": "2.0",
    "method": "Onvif.Add",
    "params": {
        "cameraID0": {
            "hostname": "192.168.204.25",
            "events": {
                "MotionAlarm": "dvr|live|capture|publish",
                "PowerAlarm": "dvr|publish"
            }
        },
        "cameraID1": {
            "hostname": "192.168.204.26",
            "events": {
                "MotionAlarm": "dvr|live|capture|publish",
                "PowerAlarm": "dvr|publish"
            }
        }
    },
    "id": 1
}'
PHP
PHP
$data = array (
  'jsonrpc' => '2.0',
  'method' => 'Onvif.Add',
  'params' => 
  array (
    'cameraID0' => 
    array (
      'hostname' => '192.168.204.25',
      'events' => 
      array (
        'MotionAlarm' => 'dvr|live|capture|publish',
        'PowerAlarm' => 'dvr|publish',
      ),
    ),
    'cameraID1' => 
    array (
      'hostname' => '192.168.204.26',
      'events' => 
      array (
        'MotionAlarm' => 'dvr|live|capture|publish',
        'PowerAlarm' => 'dvr|publish',
      ),
    ),
  ),
  'id' => 1,
);
$context = stream_context_create([
	'ssl'=>['verify_peer' => false],
	'http' => [
		'method' => 'POST',
		'header' => "Content-Type: application/json\r
Accept: application/json\r
Authorization: Bearer <api-authorization-token>\r
Content-Length: <data length>",
		'content'=>json_encode($data)
	]
]);
$result = file_get_contents('https://your-domain/api/', false, $context);

200 OK

The UID of an added stream

JSON
"<stream-uid>"

400 Bad Request

The JSON-RPC error

JSON
{
    "error": {
        "code": -32601,
        "message": "Method not found"
    }
}

500 Internal Server Error

The server error

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.