How to send commands to trackers using REST API
This guide will show you how to send commands to a tracker using REST API and how to send commands to multiple assets within a Tag.
Requisites
The Commands REST API resource requires the following information when using it:
- Read how to enable REST API
- Read how to generate the REST API token
- Read how to obtain an application ID
- Read how to obtain the userID from a asset
- Read how to obtain the deviceID from a Tag of users/assets
Resources used
- Commands > Get
- Commands > Post
See available commands
This step is optional, but helps to retrieve already available commands from the trackers.
To see the available commands for a tracker follow these steps:
1. Log in to http://host_name/comGpsGate/api/v.1/test
Note: replace host_name with your actual server IP address or DNS name.
2. Click on the resource name GET/applications/...../commands> Try it out option.
3. Enter the following details:
- applicationid = the ID of the application. Read here how to obtain it.
- userid = the ID of the asset with privileges to read those commands. Read here how to obtain it.
- deviceid = the ID of the tracker. You can obtain it the same way as applicationid, entering the name of the asset instead. If you want to obtain the deviceID of multiple trackers, Read how to obtain the deviceID from a Tag of users/assets.
If the commands are available, they will be listed under the Response area
Sending the command
1. Log in to http://host_name/comGpsGate/api/v.1/test
Note: replace host_name with your actual server IP address or host name.
2. Click on the resource name POST/applications/...../commands> Try it out option.
3. Enter the following details:
- applicationid = the ID of the application. Read here how to obtain it.
- userid = the ID of the asset with privileges to read those commands. Read here how to obtain it.
- deviceid = the ID of the tracker. You can obtain it the same way as applicationid, entering the name of the asset instead. If you want to obtain the deviceID of multiple trackers, Read how to obtain the deviceID from a Tag of users/assets.
- command = the command you want to send to the tracker, for example:
{
"command": "getinfo"
}
Note: make sure your tracker is compatible with the command you try to send. Check your tracker documentation to send the right commands to your trackers.
If the command was successful, you will see the 200 state and the Response below: