peter
2 months agoCato Employee
A simple example in Python
import json
import ssl
import urllib.parse
import urllib.request
headers = {
"x-api-key": MY_API_KEY,
"Content-Type": "application/json"
}
body = {
"operationName": "accountSnapshot",
"variables": {"accountID":MY_ACCOUNT_ID},
"query": '''
query accountSnapshot($accountID:ID!) {
accountSnapshot(accountID:$accountID) {
id
}
}'''
}
request = urllib.request.Request(url='https://api.catonetworks.com/api/v1/graphql2',
data=json.dumps(body).encode("ascii"),
headers=headers)
response = urllib.request.urlopen(request, context=ssl._create_unverified_context())
print(json.loads(response.read().decode("utf-8","replace")))