Use rest api in airwatch

Hi,

I would like to start using rest api for an AirWatch 9.2.1 on prem installation . I know a little about Javascript and some nodeJS and I think (hope) it should be enough to write some simple scripts. Unlikely I really don’t know where to start.
Could someone make an example of how to authenticate via rest api and make some simple queries, like the list of all devices?

Thank you in advance
Giorgio

Hi Giorgio,
You might find useful this URLs to VMware publicly available examples :
Execute-AirWatch-Rest-API-Call/Execute-AWRestAPI.ps1 at master · vmwarecode/Execute-AirWatch-Rest-API-Call · GitHub

this is the url to pdf with REST API guide
VMware Workspace ONE UEM Documentation

VMware stopped creating those from v9.2, instead you can access online API documentation via URL
https://<Airwatch_server_URL>/api/help

1 Like

Hi Greg,

thank you for the reply!
With te examples I managed to make first queries, but I found a behavior that may need some modifies on AirWatch: when I query https://aw_server/api/mdm/devices/search I get a json of just 500 devices, even if devices registered on AW are more than 1500…

Do you know if there is a global variable to edit in order to raise the limit of devices per query, or something like that?

Really thank you again
Giorgio

Hi,

you can try this /api/mdm/devices/search?pagesize=10000

2 Likes

Thank you, this solved!

I tried to download devices information which are more than 1500+ but i can get only 500 , even i tried /api/mdm/devices/search?pagesize=10000 but no use

Hi Mahesh,

Idea is to pickup from the first call difference between total number of items and pagesize and calculate number of pages if required, then issue same call with increased number of the page and save result as arraylist (or whatever your preferred method is):

Syntax below is powershell:

            #make first call
            $returnvalue = New-Object System.Collections.ArrayList
            $URI = <whatever uri you need>
            $Response = Invoke-RestMethod -Uri $URI -DisableKeepAlive -Headers $Headers -Body $Body -Method $Method -ErrorAction SilentlyContinue
             $returnvalue = $returnvalue + $Response


    If  (($Response.Total - $Response.PageSize) -gt 0) {
	#calculate required number of pages 
	$NumberOfPagesToAdd = [math]::Truncate($Response.Total/$Response.PageSize)		
	#cycle through all $NumberOfPagesToAdd
	$i=1
			do {
				$URI = <whatever uri you need> + "&page=" + $i	
				#Remove-variable -Name "TempResponse"  -Force -EA SilentlyContinue
				$TempResponse = Invoke-RestMethod -Uri $URI -DisableKeepAlive -Headers $Headers -Method $Method -ErrorAction SilentlyContinue
				$returnvalue = $returnvalue + $TempResponse
				$i++
			} while ($i -le $NumberOfPagesToAdd)
     }