Elmark
Joining the Conversation
21 days agoPermission errors when testing Cato API with Python
HI all, I am currently working on a project to automate workflows in Cato with Python. I've already set and reviewed my API permissions and they should already inherit my account which is able to edit and view most of the resources.
However, I still get this error:
HTTP 200
{
"errors": [
{
"message": "permission denied",
"path": [
"licensing",
"licensingInfo"
],
"extensions": {
"code": "Code104"
}
}
],
"data": {
"licensing": {
"licensingInfo": null
}
}
}
I've been scouting the documentation on specific troubleshooting steps but I couldn't seem to find the answers i'm looking for. Any chance some folks could give me a quick guide on how to ensure I get the right permissions for my API keys?
This is the sample script i'm testing btw, it is to pull available licensing information for monitoring.
API_KEY = os.getenv("CATO_API_KEY")
API_URL = "https://api.catonetworks.com/api/v1/graphql2"
QUERY = """
{
licensing(accountId: <ID_HERE>) {
licensingInfo {
globalLicenseAllocations {
ztnaUsers {
total
allocated
available
}
}
}
}
}
"""
async def main():
headers = {
"x-api-key": API_KEY,
"Content-Type": "application/json"
}
async with aiohttp.ClientSession(headers=headers) as session:
async with session.post(API_URL, json={"query": QUERY}) as resp:
print("HTTP", resp.status)
print(json.dumps(await resp.json(), indent=4))
asyncio.run(main())