AirWatch: How to use the REST API
According to the "AirWatch REST API Guide" PDF document that you can get in https://my.air-watch.com, you need:
the URL : https://<host>/API/v1/help
the Token: aw-tenant-code (or API Key)
Authorization: Basic base64.b64encode("username:password")
How to find the Token
Select the right Organization Group
Go to Group & Settings > System > Advanced > API > REST > General
Select "Override"
an API Key will be generated. This is your "aw-tenant-code"
How to Authorize
The easiest way is to use Basic authentication.
Make sure your admin has the correct role. In production, you should create a custom Role, but for test, Console Administrator is fine. Make sure he's in the correct OG, of course.
The form should be "username:password", encoded using Base64. You can do this on OS X terminal (see below)
$ python -c "import base64; print base64.b64encode('login:password')" bG9naW46cGFzc3dvcmQ= $
How to test with Curl
$ curl -X "GET" "https://host.awmdm.com/API/v1/help" \ -H "Authorization: Basic bG9naW46cGFzc3dvcmQ=" \ -H "aw-tenant-code: bG9naW46cGFzc3dvcmFzZG/2FmYXNkZmFkc2Zhc2Zk="
With Python
# Install the Python Requests library: # `pip install requests` import requests def send_request(): # My API # GET https://host.awmdm.com/API/v1/help try: response = requests.get( url="https://host.awmdm.com/API/v1/help", headers={ "Authorization": "Basic bG9naW46cGFzc3dvcmQ=", "aw-tenant-code": "bG9naW46cGFzc3dvcmFzZGZ/2FmYXNkZmFkc2Zhc2Zk=", }, ) print('Response HTTP Status Code: {status_code}'.format( status_code=response.status_code)) print('Response HTTP Response Body: {content}'.format( content=response.content)) except requests.exceptions.RequestException: print('HTTP Request failed')
Or just use Paw https://luckymarmot.com/paw ;-)
One More Thing…
It doesn't work with OS X clients:
<AirWatchFaultContract xmlns="http://www.air-watch.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <ActivityId>56b6ed75-30a2-418e-84fa-f8e04d35506a</ActivityId> <ErrorCode>501</ErrorCode> <Message>Functionality not supported for device type : AppleOsX</Message> </AirWatchFaultContract>