PAN-OS 9.0.6 API Curl JSON output

cancel
Showing results for 
Search instead for 
Did you mean: 

PAN-OS 9.0.6 API Curl JSON output

L1 Bithead

I'm working on a project to get information from the Palo Altos and use it for an input to a SIEM.  I'm able to run the below and get XML output.

curl -k 'https://<PAN>/api/?type=op&cmd=<show><system><info></info></system></show>&key=<KEY>'

I would prefer getting this in json so I tried &output-format=json after the key and get XML.  I did some research and see that /api appears to be XML output only.  Is this the case?  If so, is there an alternate to get the same output but in json?

 

TIA,

Joe

10 REPLIES 10

L1 Bithead

Assuming that you're using a Linux CLI for this: a combination of the xpath (or xmllint) and the logger commands might be an easy solution to achieve your goal.

 

Here's a good example:

curl --insecure 'https://10.1.1.1/api/?type=op&cmd=<show><session><info></info></session></show>&key=XXXXXXXXXXXXXXXXXXXXXXXX=' -s | xpath "//pps/text()" 2>/dev/null | xargs logger -t paloaltoapi -n 10.3.3.7 -P 514 Number of sessions from Palo Alto firewall:
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!