FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
377 views 0 comments
by anonymous
Working (GET):

sudo curl -X GET "http://192.168.1.1/cgi-bin/io_state?username=XXX&password=XXX&pin=relay0&state=open"

Respons: OK

Not working (POST):

sudo curl -X POST "http://192.168.1.1/cgi-bin/io_state?username=XXX&password=XXX&pin=relay0&state=open"

Response: Bad username or password

I want to be able to POST the relay to OPEN in 30 sec. The reason for it is that the relay control the power to my computer, and I want to shutdown my computer correctly before the power went out. So I can not have a GET, because then I have to wait.

Regards Terje

Replya minute ago

1 Answer

0 votes
by anonymous

Hello,

Both GET and POST are used to transfer data, requests from client to server in HTTP, however, there is a difference in how POST and GET requests are represented. GET requests are appended in URL strings. POST request in itself means sending information in the body. It is not possible to send POST parameters in the URL in a straightforward manner. 

You can read more about POST request creation here: https://linuxize.com/post/curl-post-request/.

You can also use Chrome's add-on Postman for testing purposes: https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop

It should also work if you were to simply enter: curl "http://192.168.1.1/cgi-bin/io_state?username=XXX&password=XXX&pin=relay0&state=open"

Best regards,

Žygimantas