- This topic has 1 reply, 2 voices, and was last updated 6 years, 8 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
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
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:
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!!
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.
OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Bee (OSBee) › Sending a cp command via CURL with JSON data