Skip to main content
Skip table of contents

Pоst an event: Server.PostEvent

The method and parameters

The Server.PostEvent method posts an event to the Mediaserver.

string Server.PostEven(EventObject event0, EventObject event1mixed ... )

Параметры

EventObject event0 REQUIRED – the event name to be posted.

object EventObject

string event0.hostname = 192.168.204.25– the camera address.


string event0.payload = Hello from camera-uuid-0– the body of the event.


string event0.source = camera-uuid-0 – the identifier of the event source.


string event0.type = dvr|live|capture|publish – the type of the event.


EventObject event1 REQUIRED – the event name to be posted.

object EventObject

string event1.hostname=192.168.204.27 – the camera address.


string event1.payload = Hello from camera-uuid-1 – the body of the event.


string event1.source = camera-uuid-1 – the identifier of the event source.


string event1.type = dvr|live|capture|publish – the type of the event.


POST /api/

JSON-RPC
JSON
{
    "jsonrpc": "2.0",
    "method": "Server.PostEvent",
    "params": {
        "event0": {
            "hostname": "192.168.204.25",
            "source": "camera-uuid-0",
            "type": "dvr|live|capture|publish",
            "payload": "Hello from camera-uuid-0"
        },
        "event1": {
            "hostname": "192.168.204.27",
            "source": "camera-uuid-1",
            "type": "dvr|live|capture|publish",
            "payload": "Hello from camera-uuid-1"
        }
    },
    "id": 1
}
cURL
BASH
curl -k --request POST \
	--url 'https://your-domain/api/' \
	--header 'Content-Length: 513' \
	--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": "Server.PostEvent",
    "params": {
        "event0": {
            "hostname": "192.168.204.25",
            "source": "camera-uuid-0",
            "type": "dvr|live|capture|publish",
            "payload": "Hello from camera-uuid-0"
        },
        "event1": {
            "hostname": "192.168.204.27",
            "source": "camera-uuid-1",
            "type": "dvr|live|capture|publish",
            "payload": "Hello from camera-uuid-1"
        }
    },
    "id": 1
}'
PHP
PHP
$data = array (
  'jsonrpc' => '2.0',
  'method' => 'Server.PostEvent',
  'params' => 
  array (
    'event0' => 
    array (
      'hostname' => '192.168.204.25',
      'source' => 'camera-uuid-0',
      'type' => 'dvr|live|capture|publish',
      'payload' => 'Hello from camera-uuid-0',
    ),
    'event1' => 
    array (
      'hostname' => '192.168.204.27',
      'source' => 'camera-uuid-1',
      'type' => 'dvr|live|capture|publish',
      'payload' => 'Hello from camera-uuid-1',
    ),
  ),
  '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

bool – the operation execution result.

JSON
true

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.