Skip to main content

Restarting Devices with API

What

Like to restart many devices in bulk?  API can deliver this.

How

The data block for posting restart commands relies upon the 'ids' of devices.  This is the Client ID as either viewed in the Client View or as shown when creating Inventory Queries with Client ID added.

Establish a list of device Client IDs that require rebooting.  These should be supplied as a comma separated list of integers.  Inventory Queries could assist with obtaining the list.

Both the API URL and the data block for the API request is different per OS.

In each of the below, an example server names has been supplied 'demo.filewave.ch'.  This should be altered to match the FileWave Server's address as seen in the Mobile tab of Preferences in the FileWave Central App.

Example Server Name:

image.png

Android

Example device:

image.png

API URL:
"https://demo.filewave.ch/api/android/restart_devices"
Data Block:
{
  "ids": [
    54290
  ]
}

Apple

Example device:

image.png

API URL
"https://demo.filewave.ch/api/devices/v1/devices/mdm-command"
Data Block
{
  "ids": [
    54000
  ],
  "command": "RestartDevice"
}

Windows

Example device:

image.png

API URL
"https://demo.filewave.ch/api/devices/v1/devices/windows-restart"
Data Block
[
  {
    "ids": [
      54028
    ]
  }
]

Example:

To restart two Apple devices, whose Client IDs are 737581 and 562620, as well as requiring the server's FQDN, the API token is also required.  Administrator  API Tokens are available from:

  • FileWave Central Admin App > Manage Administrators > [select a user] > Application Tokens (tab)

Tokens are unique per user and each user may have multiple tokens

image.png

Different tokens could be used for different tasks.  Consider creating a user specific for API or multiple API users, depending upon requirements, and limit each API user's 'Permissions' to only those items required to achieve the API request(s).

Alter the 'ids' list, server FQDN and API Authorisation Token as required

macOS/Linux:
mdm_command='{"ids": [737581, 562620],"command": "RestartDevice"}'

curl -H "Authorization: ezlmZjJkMDZhLTg1YWEtNDY5Ny04NDYzLTVjMGU3MjhjODEyN30=" \
  -X POST https://demo.filewave.ch/api/devices/v1/devices/mdm-command \
  -d "$mdm_command" \
  -H "Content-Type: application/json"
Windows:
$mdm_command = '{"ids": [737581, 562620],"command": "RestartDevice"}'

$header = @{Authorization=“ezlmZjJkMDZhLTg1YWEtNDY5Ny04NDYzLTVjMGU3MjhjODEyN30="}

Invoke-RestMethod -Method POST \ 
    -Headers $header \
    -ContentType application/json \
    -Uri https://demo.filewave.ch/api/devices/v1/devices/mdm-command \
    -Body $mdm_command