RESTful Communication - MIP .NET

The RestfulCommunication sample demonstrates how to create, get, update and delete a user-defined event. The sample also shows how to invoke a ptzPresets task on a camera that supports PTZ. The status of the invoked task can be seen using the sample.

Making the REST API call is done using a bearer token in the authorization header. A token cache holds the current token that gets refreshed every hour internally. The token cache is set by the MIP SDK upon successful login.

RestfulCommunication

Prerequisites

The sample demonstrates

Notes

Tasks

In this sample, if the selected request URI contains the placeholder parameters {userDefinedEventId}, {ptzCameraId}, {task}, or {taskId}, you must replace the placeholder with a proper value before sending the request.

When you get all the available tasks for a PTZ camera, the response body will look like this:

{
    "tasks": [
        {
            "id": "DefaultPtzPreset",
            "displayName": "Set default PTZ preset"
        },
        {
            "id": "GetDevicePresets",
            "displayName": "Get presets from camera"
        }
    ]
}

To invoke a task you, provide the id value (e.g. "DefaultPtzPreset", "GetDevicePresets" etc.) as a {task}.

The response body will have the id value of the invoked task (in this case 81) as shown below:

{
    "result": {
        "sessionDataId": 0,
        "state": "Idle",
        "path": {
            "type": "tasks",
            "id": "81"
        }
    }
}

The status of the task can be checked using the id value as {taskId} in the request URI, and the final result will look like:

{
    "data": {
        "displayName": "invokeResult",
        "progress": 100,
        "cameraPath": {
            "type": "cameras",
            "id": "93345da5-de2b-415c-afe3-968f4b28cccd"
        },
        "sessionDataId": 6,
        "affectedProfileIds": [],
        "state": "Success",
        "relations": {
            "parent": {
                "type": "sites",
                "id": "bc4fe0ba-186f-40bc-ab6e-704d55a0aff5"
            },
            "self": {
                "type": "tasks",
                "id": "81"
            }
        }
    }
}

Using

Environment

Visual Studio C# project