VMware Workspace ONE Community
elementalgary
Contributor
Contributor

MDM REST API V1 POST /devices/{deviceid}/commands

I'm trying to use the MDM REST API to perform a SoftReset command on a device. However, the API explorer doesn't have enough detail for me to see how to populate the Parameter customCommandModel. It is required and the example provided is in this format: {' CommandXml' : ' Text value' }, but using this example with the parameter command SoftReset only yields a 422 Response Code and this error:

{
  ' errorCode' : 1012,
  ' message' : ' Element: customCommandModel Message: Malformed XML. or r or n' ,
  ' activityId' : ' 09ccd868-1284-4060-bf2e-e16911fc0830'
}

I would like an example of how to use the SoftReset command.

Labels (1)
Reply
0 Kudos
6 Replies
volperj
Contributor
Contributor

Hi Gary,
You can put the command as a GET parameters in the query for example ' https://YOUR_SERVER/api/mdm/devices/DEVICE_ID/commands?command=SoftReset'
If you want to send others command you replace the ' SoftReset'  parameter with the wanted parameter.

Hope this help you
Reply
0 Kudos
elementalgary
Contributor
Contributor

I tried changing the POST to a GET (which isn't in the documentation) and it didn't work. It returned a webpage with the error: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.
Reply
0 Kudos
volperj
Contributor
Contributor

It's a POST request not GET, but you can specify your parameters directly in the URL (as a GET parameters).
Example of CURL request : curl --request POST  --url 'https://YOUR_SERVER/api/v1/mdm/devices/DEVICE_ID/commands?command=SoftReset'  --header 'authorization: Basic BASE64_USERNAME_PASSWORD’  --header 'aw-tenant-code: AW_TENANT_CODE’
Reply
0 Kudos
elementalgary
Contributor
Contributor

I've tried using the POST but got this error. The API Explorer seems to suggest that the CommandXml data is required:

% curl -X POST --header 'Accept: application/json' --header 'Authorization: Basic Z2ReplacedWithMyAuthA=' --header 'aw-tenant-code: 2DReplacedWithMyAWtenantcodevc=' 'https://as35.airwatchportals.com/api/mdm/devices/318532/commands?command=SoftReset'

Length Required

Length Required




HTTP Error 411. The request must be chunked or have a content length.



Reply
0 Kudos
elementalgary
Contributor
Contributor

FYI, I've been informed by my AirWatch reseller technical support that it is not possible to reboot the device via API. There is a feature request for support of this on Android Managed, but not a regular Android BYOD.
Reply
0 Kudos
JoelMcGee
Contributor
Contributor

I am trying to use this URI for the DeviceQuery command and I receive the same 422 response.

Reply
0 Kudos