Show contents 

Development > Server API > Method for Working with Mobile Devices

Method for Working with Mobile Devices

To work with mobile devices, execute requests using the "devices" API method (determine administrator token before executing the request):

curl -X POST -v '<IP address or DNS server name>/api/v2/devices/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>' -d '{
    "id_string": "<device identifier>",
    "is_active": <indicates whether device is active (true/false)>,
    "os_version": "<Device OS version (ANDROID, IOS, UWP, OTHER)>"
}'

The example of response:

{
    "id": 5,
    "id_string": "device4",
    "is_active": true,
    "registration_date": "2022-06-06T10:58:03.516823+03:00",
    "last_enter": null,
    "os_version": "IOS"
}

curl -X GET '<IP address or DNS server name>/api/v2/devices/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>'

The example of response:

{
    "count": 2,
    "next": null,
    "previous": null,
    "results": [{
        "id": 1,
        "id_string": "new_device",
        "is_active": true,
        "registration_date": "2023-12-13T18:52:48.792770+04:00",
        "last_enter": "2024-01-24T13:34:26.927070+04:00",
        "active_users_count": 1,
        "os_version": "OTHER"
   },{
        "id": 2,
        "id_string": "11",
        "is_active": true,
        "registration_date": "2024-01-16T11:26:47.227645+04:00",
        "last_enter": "2024-01-16T11:26:47.262803+04:00",
        "active_users_count": 0,
        "os_version": "OTHER"
    }]
}

Parameter values contain the following information about each mobile device:

curl -v '<IP address or DNS server name>/api/v2/devices/<requested device identifier>/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>'

In the <requested device identifier> substitution use value of the id parameter returned on getting the list of mobile devices.

The example of response:

{
    "id": 3,
    "id_string": "device2",
    "is_active": true,
    "registration_date": "2022-06-06T10:29:49.320247+03:00",
    "last_enter": null,
    "active_users_count": 0,
    "os_version": "UWP"
}

curl -X PUT -v '<IP address or DNS server name>/api/v2/devices/<requested device identifier>/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>' -d '{
    "id_string": "<device identifier>",
    "is_active": <indicates whether device is active (true/false)>,
    "os_version": "<Device OS version (ANDROID, IOS, UWP, OTHER)>"
}'

In the <requested device identifier> substitution use value of the id parameter returned on getting the list of mobile devices.

The example of response:

{
    "id": 3,
    "id_string": "new_name",
    "is_active": false,
    "registration_date": "2022-06-06T10:29:49.320247+03:00",
    "last_enter": null,
    "active_users_count": 0,
    "os_version": "ANDROID"
}

curl -v '<IP address or DNS server name>/api/v2/devices/<identifier or requested device>/api-users/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>'

In the <requested device identifier> substitution use value of the id parameter returned on getting the list of mobile devices.

The example of response:

{
    "results": [
        {
            "id": 6,
            "environment_name": "environment",
            "project_name": "project",
            "username": "user11",
            "devices_count": 1,
            "is_active": true
        },
        {
            "id": 7,
            "environment_name": "environment",
            "project_name": "project",
            "username": "user22",
            "devices_count": 1,
            "is_active": true
        }
    ]
}

curl -X DELETE '<IP address or DNS server name>/api/v2/devices/<identifier of requested device>/api-users/<user identifier>/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>'

In the <requested device identifier> substitution use value of the id parameter returned on getting the list of mobile devices, and in the <user identifier> substitution use value of the username parameter returned on getting the list of API users.

The example of response:

204 No Content

curl -X DELETE -v '<IP address or DNS server name>/api/v2/devices/<requested device identifier>/' --header 'Content-Type: application/json' -H 'Authorization: Bearer <administrator token>'

In the <requested device identifier> substitution use value of the id parameter returned on getting the list of mobile devices.

The example of response:

204

See also:

Server API