Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


Submitting a POST Request to the REST API

Use an HTTP POST request to send single or multiple RPC requests to the REST API. You can use the POST request to do device configuration.

For a single rpc command, the general format of the endpoints is:


  • scheme: http or https

  • method: The name of any Junos OS rpc command. The method name is identical to the tag element. For more information, see the Junos XML Protocol Operations, Processing Instructions, and Response Tags in the Junos XML Management Protocol Developer Guide and the Junos XML API Operational Developer Reference.

  • params: Optional parameter values (name[=value]).

To authenticate your request, submit the base64-encoded username and password included in the Authorization header:

To specify rpc data as a query string in the URI for POST requests, submit the query data in the POST body. In such cases you can specify the Content-Type as text/plain or application/xml, as shown in these equivalent cURL calls:

For both single and multiple RPC commands, HTTP Accept headers can be used to specify the return format using one of the following Content-Type values:

  • application/xml (the default)

  • application/json

  • text/plain

  • text/html

For example, the following cURL call specifies an output format of JSON:

You can also specify the output format using the optional format attribute:


The default Content-Type for POST requests containing arguments in the body is application/xml. If you want to use any other content, such as a query string, you can specify a Content-Type of text/plain. Specify the format attribute in configuration commands.

When executing multiple rpc commands in a single request, the general format of the endpoint is:


The RPCs must be provided as XML data in the POST body. The Content-Type for the response is multipart/mixed, with boundary and subtype associated with the output from each RPC execution. The format specified in the Accept header is used as the output format for each of the RPCs if they are missing a format attribute. If an Accept header is not specified and no format attribute is specified in a given RPC, the default output format is XML. For example, to send a single HTTP request to execute the RPCs get-software-information and get-interface-information, submit a POST request to /rpc with "Auth: Basic <base64hash>", "Content-Type: application/xml". The POST body would contain:


Here is a cURL call using this POST body:

The output from the request, containing XML as the default, would appear as follows:

You can also specify the output format for each of the elements in the POST body. For example, the following request emits JSON for the get-interface-information RPC and plain text for the get-software-information RPC:

When executing multiple RPCs, if an error occurs, the default behavior is to ignore the error and continue execution. If you want to exit when the first error is encountered, specify the stop-on-error flag in the URI. For example, the following request configures the device and terminates if an error is encountered: