OpenSprinkler Forums Hardware Questions OpenSprinkler Bee (OSBee) Sending a cp command via CURL with JSON data

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #63198

    jolaca01
    Participant

    Hi, I’m really happy with my OS Bee, now I want to be able to send commands to be able to change a program. The data I used is from the JSON received using command jp
    So, my problem is that I have no problem changing a program doing this for example:

    curl -g ‘http://myIP/cp?dkey=myPassword&pid=0&config=65666&sts=%5B1260,-1,-1,-1,-1%5D&nt=3&pt=%5B153601,184322,184324%5D&name=’Atardecer”

    however if I try to send this same command with the originally program data in JSON format, like this:

    curl -H “Content-Type: application/json” ‘http://myIP/cp’ -g -d ‘{“dkey”:”myPassword”,pid”:0,”config”:65539,”sts”:[1260,-1,-1,-1,-1],”nt”:3,”pt”:[153601,184322,184324],”name”:”Atardecer”}’

    I get this answer: {“result”:2,”item”:””} In other words ‘unauthorized’ as if it didn’t read my ‘dkey’ parameter or all the rest of JSON data.
    Could you please help me out to know how I can send the CURL using the same JSON format received. I think I’m very close but I’m stuck at this point.
    Using -v for getting more info, this is what I get:
    * TCP_NODELAY set
    * Expire in 200 ms for 4 (transfer 0x131c7c0)
    * Connected to myIP (#0)
    > POST /cp HTTP/1.1
    > Host: myIP
    > User-Agent: curl/7.64.0
    > Accept: */*
    > Content-Type: application/json
    > Content-Length: 30
    >
    * upload completely sent off: 30 out of 30 bytes
    < HTTP/1.1 200 OK
    < Content-Type: text/html
    < Content-Length: 22
    < Connection: close
    < Access-Control-Allow-Origin: *
    <
    * Closing connection 0

    It seems that it have read the json data but nevertheless it returns ‘unauthorized’ as if it didn’t read ‘dkey’ parameter properly ¿?¿?
    Thank you in advance for your help!!

    • This topic was modified 1 week, 6 days ago by jolaca01.
    • This topic was modified 1 week, 5 days ago by jolaca01.
    • This topic was modified 1 week, 5 days ago by jolaca01.
    • This topic was modified 1 week, 5 days ago by jolaca01.
    #63234

    Ray
    Keymaster

    The firmware only accepts GET command. I am not familiar with the way you send via CURL with JSON data, but when it gets to the firmware it needs to be in GET command as specified. It will not accept other formats, and it won’t handle POST data either.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Hardware Questions OpenSprinkler Bee (OSBee) Sending a cp command via CURL with JSON data