Junos OS

 View Only
last person joined: 4 days ago 

Ask questions and share experiences about Junos OS.
  • 1.  Junos REST API Failed to open session to execute RPC

    Posted 05-23-2022 11:46
    I'm trying to start using Junos OS REST API on my SRX 300 but whenever I try to query the RPC endpoint I always get the following error even though I'm trying to log in using an admin account. I'm unable to enable logging for lighttpd because the file system it tries to write the log to is write only. Is there some configuration I need to do in order to authorize an user to the API or should it work by just enabling the API and using any account on the device to log in? I'm assuming that the error being 401 would mean that the user is unauthorized to use the API. The build version is "JUNOS 17.4R1.16 built 2017-12-19 19:58:10 UTC". I would truly appreciate if anyone could help me on this one because I can't find any documentation regarding this behaviour and I haven't been able to find other cases of people trying to solve a similar case. Thanks in advance for any help!

    Response Headers

    date: Mon, 23 May 2022 14:49:04 GMT server: lighttpd/1.4.32 status: 401 transfer-encoding: chunked

    Response Body

    Failed to open session to execute RPC


    ------------------------------
    Matias Hamalainen
    ------------------------------


  • 2.  RE: Junos REST API Failed to open session to execute RPC

    Posted 05-23-2024 19:23

    When the REST config and curl commands are correct, I have seen this error when there are special characters in the password. It occurs with or without '\'.  In the example below I removed the special characters but one can also use quotes strategically as another way to get around this. 

    ************************ FAILED: Special characters ************************

    root@switch% curl -i -u "juniper:juniper!" http://X.X.X.X:3000/rpc/get-interface-information

    HTTP/1.1 401 Unauthorized

    Status: 401

    Content-Length: 38

    Date: Thu, 23 May 2024 17:46:09 GMT

    Server: lighttpd/1.4.48

     

    Failed to open session to execute RPC

    ************************ SUCCESS: No special characters ************************

    root@switch:0% curl -i -u "juniper:juniper" http://X.X.X.X:3000/rpc/get-interface-information

    HTTP/1.1 200 OK

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

    Transfer-Encoding: chunked

    Date: Thu, 23 May 2024 17:50:53 GMT

    Server: lighttpd/1.4.48

     

    <interface-information xmlns="http://xml.juniper.net/junos/22.4R0/junos-interface" xmlns:junos="http://xml.juniper.net/junos/*/junos" junos:style="normal">

    <physical-interface>

    <name>gr-0/0/0</name>

    <admin-status junos:format="Enabled">up</admin-status>

    <oper-status>up</oper-status>

    ...



    ------------------------------
    Jessica Garrison
    ------------------------------