Pulling reports using the XML API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Please sign in to see details of an important advisory in our Customer Advisories area.
Cyber Elite
Cyber Elite

Network and security admins usually spend their days putting out fires and fixing problems. Scripts and automated tasks are our little helpers that ensure that at the end of the day, we managed to clear the important tasks even though we were interrupted 5 thousand times because 'the firewall broke something' again.

 

Jobs need to be run, backups need to be taken and reports need to be created.

 

In this video tutorial, Jason Yates from the Global Enablement Team shows you how to access the API interface, which options are available, how the XML API works and how to leverage the API to fetch reports.

 

 

Some key commands and pointers:

 

  • Create a separate admin account for the API access with an appropriately restrictive admin role
  • Generate an API key
    https://<hostname>/api/?type=keygen&user=<username>&password=<password>
  • Add the key to the GET command
    https://<hostname>/api/?type=report&reporttype=predefined&reportname=<ReportName>&key=<APIkey>

 

Why not make your life a little easier? Feel free to leave a comment or ask a question in the comments below.

 

Reaper out!

10 Comments
L1 Bithead

Excellent video Jason. Thanks.

L1 Bithead

Hi Jason,

 

Great video!

 

Out of interest what software/application  do you recommend importing the XML code into to view the reports?

 

I'm just after something simple to set up in a lab fairly quickly to see how I could use the reports in a single pain of glass.

 

Thanks

 

NetworkZeus

L0 Member

Thanks for the video!

 

As I've worked with Palo Alto api I've come across an issue.

 

I'm interested in getting the list of predefined reports through the api. I am running version 7.1.2 of the api.

 

As I've looked through documentation I've found this: https://www.paloaltonetworks.com/documentation/71/pan-os/xml-api/pan-os-xml-api-request-types/predef....

 

This page says that this is a valid api request: https://firewall/api/?type=report&reporttype=predefined.

 

When I run this request though, I'm told that I need to define the reportname. I'm not interested in defining the report name, however, and just interested in getting the list of the reports. Any idea of how I can do this?

Cyber Elite
Cyber Elite

Hi @zormond

the command you're using is intended to fetch the content of a report, while if you want a list of all the available reports, you can use the API browser :

https://firewall/php/rest/browse.php/report::predefined 

 

you can access the API browser root by navigating to https://firewall/api 

L0 Member

All right, thanks!

 

Just to verify that I understand, you're saying that this url "https://firewall/api/?type=report&reporttype=predefined" was never intended to give back the list of available reports, but only to give back the requested report defined by the reportname field?

 

The reason I ask this is because I'm making my own API right now and I want to try to get the list of reports dynamically instead of hardcoding into my API. 

 

Thanks again.

L0 Member

Hi, 

It's a really great and informational video. I'm trying to put together a few scripts to automate my tasks and I've run into a few issues which aren't really covered by the video.

 

If there's a particluarly lengthy report job e.g. detailed traffic stats over the last year, is there any way using the job ID to query the status of the job? From what I've found, this is possible when generating a tech support dump but I've yet to find this for reports.

 

Is it possible to call an existing custom report on a specific firewall vsys using the API but provide a different start and end time to the times defined in the configuration? 

 

Thank you

L2 Linker

Is there any way to automate report generating through the API on a weekly basis?

L0 Member

Looks like I'm a little late to the party, but has anyone pulled these XML reports into Power BI?

L2 Linker

@mr.mike I wondered the same.  new with PowerBI but thought I would see if anyone here in community had made any success.

L0 Member

Is it possible to do this without the API permissions on the Admin Role being set to Enabled?
A service account for this sort of thing shouldn't have write access, but Read Only seems to only work for the Web UI permissions.

  • 40986 Views
  • 10 comments
  • 3 Likes
Register or Sign-in
Labels
Top Liked Authors