Thank you for the solution. Its prettier now. 😄
- Now its a bit clearer to me. POST initiate the ping, GET prints the result of the ping.
- The POST generates a pingID that is used as a parameter for the GET command.
Below is the result if the POST command:
{
"pingId": "ZZZZZZZZZZZZZZZZZZZZZZZZ",
"url": "/devices/XXXX-XXXX-XXXX/liveTools/ping/ZZZZZZZZZZZZZZZZZZZZZZZZ",
"request": {
"serial": "XXXX-XXXX-XXXX",
"target": "10.1.19.1",
"count": 5
},
"status": "new"
}
In order to run the GET command, i need to take pingid and use it as parameter on the below command:
import requests
import json
url = "https://api.meraki.com/api/v1/devices/XXXX-XXXX-XXXX/liveTools/ping/ZZZZZZZZZZZZZZZZZZZZZZZZ"
payload = None
headers = {
"Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"Accept": "application/json"
}
response = requests.request('GET', url, headers=headers, data = payload)
response_json = json.loads(response.text)
print(json.dumps(response_json, indent=4))
Is there a way to get the pingID to auto-populate my GET script? I will be running this scripts via Task Scheduler.