Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

Requesting Operational Information Using the Junos XML Protocol

 

Within a Junos XML protocol session, a client application can request information about the current status of a device running Junos OS. To request operational information, a client application emits the specific request tag element from the Junos XML API that returns the desired information. For example, the <get-interface-information> tag corresponds to the show interfaces command, the <get-chassis-inventory> tag requests the same information as the show chassis hardware command, and the <get-system-inventory> tag requests the same information as the show software information command.

For complete information about the operational request tag elements available in the current Junos OS release, see “Mapping Between Operational Tag Elements, Perl Methods, and CLI Commands” and “Summary of Operational Request Tag Elements” in the Junos XML API Operational Developer Reference.

The application encloses the request tag in an <rpc> element. The syntax depends on whether the corresponding CLI command has any options included.

The client application can specify the formatting of the information returned by the Junos XML protocol server. By setting the optional format attribute in the opening operational request tag, a client application can specify the format of the response as either XML-tagged format, which is the default, formatted ASCII text, or JavaScript Object Notation (JSON). For more information about specifying the format, see Specifying the Output Format for Operational Information Requests in a Junos XML Protocol Session.

Note

When displaying operational or configuration data that contains characters outside the 7-bit ASCII character set, Junos OS escapes and encodes these character using the equivalent UTF-8 decimal character reference. For more information see Understanding Character Encoding on Devices Running Junos OS.

If the client application requests the output in XML-tagged format, the Junos XML protocol server encloses its response in the specific response tag element that corresponds to the request tag element, which is then enclosed in an <rpc-reply> tag element.

For XML-tagged format, the opening tag for each operational response includes the xmlns attribute to define the XML namespace for the enclosed tag elements that do not have a prefix (such as junos:) in their names. The namespace indicates which Junos XML document type definition (DTD) defines the set of tag elements in the response. The Junos XML API defines separate DTDs for operational responses from different software modules. For instance, the DTD for interface information is called junos-interface.dtd and the DTD for chassis information is called junos-chassis.dtd. The division into separate DTDs and XML namespaces means that a tag element with the same name can have distinct functions depending on which DTD it is defined in.

The namespace is a URL of the following form:

release-code is the standard string that represents the Junos OS release that is running on the Junos XML protocol server device.

category specifies the DTD.

The Junos XML API Operational Developer Reference includes the text of the Junos XML DTDs for operational responses.

If the client application requests the output in formatted ASCII text, the Junos XML protocol server encloses its response in an <output> tag, which is enclosed in an <rpc-reply> tag.

Starting in Junos OS Release 14.2, a client application can request operational and configuration information in JSON format. If the client application requests the output in JSON format, the Junos XML protocol server encloses the JSON data in the <rpc-reply> tag element.

Note

Starting in Junos OS Release 16.1, devices running Junos OS emit JSON-formatted configuration data using a new default implementation for serialization.

Release History Table
Release
Description
Starting in Junos OS Release 16.1, devices running Junos OS emit JSON-formatted configuration data using a new default implementation for serialization.
Starting in Junos OS Release 14.2, a client application can request operational and configuration information in JSON format.