: Use the CLI to Find XML API Syntax
Focus
Focus

Use the CLI to Find XML API Syntax

Table of Contents
End-of-Life (EoL)

Use the CLI to Find XML API Syntax

Another method to determine the appropriate XML syntax and XPath for your API calls is through the command-line interface (CLI). This method works for type=op and type=config API calls.
To learn about changes to the latest version of CLI commands that affect corresponding PAN-OS XML API requests, see the PAN-OS CLI Quick Start.
Use the CLI to enable debug mode and then run the CLI command to receive the corresponding XML and XPath in the response.
  1. Access the CLI.
    Use an SSH client or terminal to access your firewall or Panorama CLI.
  2. Enable debug mode.
    Enter the following command:
    						debug cli on
    					
  3. Run a CLI command.
    Enter and run a CLI command. Example:
    test url http://paloaltonetworks.com <request cmd="op" cookie="7581536015878829" uid="1206"><operations><test><url>http://paloaltonetworks.com</url></test></operations></request>
  4. Use the resulting response to create an API call.
    Use the cmd value and the XML elements within the operations tag to form the API call:
    https://<firewall>/api/?type=op&cmd=<test><url>http://paloaltonetworks.com</url></test>&key=<apikey>
    Depending on the CLI command, the XML tag values for cmd will vary. For example, here is a CLI command for showing firewall information: run show system info
    The corresponding API call looks like this:
    curl -X GET "https://<firewall>/api/?type=op&cmd=<show><system><info></info></system></show>&key=<apikey>"