Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

Junos - REST API with Multiple RPCs

‎04-16-2020 09:03 AM

Hi all,

I try to use Python requests library to get informations from Junos devices.

I would like to execute multiple RPC call on in HTTP call. I try to use Mutltipe RPCs functionnality with a POST HTTP.

https://www.juniper.net/documentation/en_US/junos/topics/example/rest-api-explorer-example.html

 

BODY :

<get-interface-information><terse/></get-interface-information>
<get-chassis-inventory><detail/></get-chassis-inventory>
<get-software-information/>
<get-system-memory-information/>

When I use Postman, the call works but the body does not seem to be formatted in a JSON / XML file ...

--harqgehabymwiax
Content-Type: application/xml; charset=utf-8

<interface-information xmlns="http://xml.juniper.net/junos/18.3R1/junos-interface" xmlns:junos="http://xml.juniper.net/junos/*/junos" 
...
...
</system-memory-information>
--harqgehabymwiax--

With a Request library it is impossible to get the Body :

r.content
-----
Result :
b'--harqgehabymwiax--\n'

Has anyone of your ever had this problem ??

 

I'm using the Juniper Sandbox :

Model: vmx
Junos: 18.3R1.9

 

Thank in advance for your feedbacks !!

Cheers,

Dylan