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 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?
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
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)
}