Unable to send RPC commands to OMV

  • Hello,
    I'm trying to add a button on Hassio in order to shutdown OMV NAS using RPC calls instead of SSH commands.
    My plan is to send 2 RPC calls: one for the login, and one for the system/shutdown command.
    During the test I'm doing, the login call works good and generate a cookie but the system/shutdows call doesn't works and say that I'm not authenticated :huh: ...

    From my PC terminal:

    $ curl --request POST --cookie-jar cookies.txt --data '{"service":"session","method":"login","params":{"username":"admin","password":"myRealPassword"}}'
    $ curl --request POST --cookie-jar cookies.txt --data '{"service":"system","method":"shutdown","params":{"delay":"15"}}'
    {"response":null,"error":{"code":5000,"message":"Session not authenticated","trace":"OMV\\ErrorMsgException: Session not authenticated in \/usr\/share\/php\/openmediavault\/session.inc:146\nStack trace:\n#0 \/usr\/share\/php\/openmediavault\/rpc\/proxy\/json.inc(81): OMV\\Session->validateAuthentication()\n#1 \/var\/www\/openmediavault\/rpc.php(45): OMV\\Rpc\\Proxy\\Json->handle()\n#2 {main}"}

    Other useful infos:
    This is the first time in my life I use RPC calls ^^ so probably I'm missing something.
    The OMV system is updated to today (version 4.1.22-1).
    I have 2 user in my OMV installation: admin and another one. I tried with both without success.
    Tried also without delay parameter.

    $ cat cookies.txt
    # Netscape HTTP Cookie File
    # https://curl.haxx.se/docs/http-cookies.html
    # This file was generated by libcurl! Edit at your own risk. FALSE / FALSE 0 X-OPENMEDIAVAULT-SESSIONID 2------deleted-----------7

    Thanks to those who want to help me.

  • Thank you ryecoaaron: you answer solved my problem. I'm sorry I disturbed you for such a trivial mistake.
    Is there a place on the internet where all "services" and "methods" are listed in a orderly manner?

    I paste here some lines, for future reference, hoping they can also be useful to other peolpe:

    LOGIN (the file cookie.txt will be generated):

    $ curl --request POST --cookie-jar cookies.txt --data '{"service":"session","method":"login","params":{"username":"admin","password":"yourpassword"}}'

    Comunication test:

    $ curl --request POST --cookie cookies.txt --data '{"service":"system","method":"noop","params":null}'
    {"response":"I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past I will turn the inner eye to see its path. Where the fear has gone there will be nothing. Only I will remain.","error":null}


    $ curl --request POST --cookie cookies.txt --data '{"service":"system","method":"shutdown","params":{"delay":10}}'
  • Is there a place on the internet where all "services" and "methods" are listed in a orderly manner?

    No but you could get them from the rpc files - https://github.com/openmediava…penmediavault/engined/rpc

    omv 5.5.23 usul | 64 bit | 5.4 proxmox kernel | omvextrasorg 5.4.5
    omv-extras.org plugins source code and issue tracker - github

    Please read this before posting a question.
    Please don't PM for support... Too many PMs!

  • Hello TheFax.

    Now that I have finished the installation of my new OMV 5.x on an RPi4 as host, I was considering "building" an interface to read data from my HA system (I currently have a few settings being sent from bash scripts via MQTT).

    Would you be willing to provide more details on how you did it on hass.io? If you think this is out of scope for this forum, can you contact me directly?

    I'd like to have HD free space, temperatures, need to go through the RPC methods' info provided by ryecoaaron above.

    Thanks in advance and kind regards.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!