SendToHTTP (GET and POST) with Headers
Moderators: grovkillen, Stuntteam, TD-er
SendToHTTP (GET and POST) with Headers
Hello.
I'm doing some experience with "SendToHTTP ", for me it's very useful.
I need to send some HTTP GET and HTTP POST with Headers, is it possible?
Here some "curl" examples that I would like to "convert" for ESPEasy:
GET:
curl -X GET -H "Authorization: Bearer VERY_LOG_TOKEN" -H "Content-Type: application/json" http://192.168.1.25:8123/api/states/sen ... r_humidity
POST:
curl -X POST -H "Authorization: Bearer VERY_LOG_TOKEN" -H "Content-Type: application/json" -d '{"state": "off"}' http://192.168.1.25:8123/api/states/switch.tapo1
Many thanks!
I'm doing some experience with "SendToHTTP ", for me it's very useful.
I need to send some HTTP GET and HTTP POST with Headers, is it possible?
Here some "curl" examples that I would like to "convert" for ESPEasy:
GET:
curl -X GET -H "Authorization: Bearer VERY_LOG_TOKEN" -H "Content-Type: application/json" http://192.168.1.25:8123/api/states/sen ... r_humidity
POST:
curl -X POST -H "Authorization: Bearer VERY_LOG_TOKEN" -H "Content-Type: application/json" -d '{"state": "off"}' http://192.168.1.25:8123/api/states/switch.tapo1
Many thanks!
Re: SendToHTTP (GET and POST) with Headers
Thanks, trying to "convert" the curl format with the ESPEasy format but it's hard...
Why don't use the same "curl" syntax like: -H "header 1 value" -H "header 2 value" so simply separate Headers by space.
In ESPEasy the is the Header separator like the space for curl?
Why don't use the same "curl" syntax like: -H "header 1 value" -H "header 2 value" so simply separate Headers by space.
In ESPEasy the
Code: Select all
%LF%
Re: SendToHTTP (GET and POST) with Headers
Headers have to be on a separate line, AFAICS, so there has to be some separator to be able to split multiple value pairs, and we chose %LF% to do that, as most other characters can be part of the header value. %LF% is the equivalent of '\n' in C++
/Ton (PayPal.me)
Re: SendToHTTP (GET and POST) with Headers
Hello.
May be can be of interest for other users. I post the original CURL command and the equivalent command (PostToHTTP) for ESPEasy rule:
HTTP POST with curl:
HTTP POST with ESPEasy:
May be can be of interest for other users. I post the original CURL command and the equivalent command (PostToHTTP) for ESPEasy rule:
HTTP POST with curl:
Code: Select all
curl -X POST -H "Authorization: Bearer VERY_LONG_HOME_ASSISTANT_TOKEN_TO_VALORIZE" -H "Content-Type: application/json" -d '{"state": "off"}' http://192.168.1.25:8123/api/states/light.shellyplus1pm_123456abc123_switch_0
Code: Select all
PostToHTTP,192.168.1.25,8123,/api/states/light.shellyplus1pm_123456abc123_switch_0,'Authorization: Bearer VERY_LONG_HOME_ASSISTANT_TOKEN_TO_VALORIZE%LF%Content-Type: application/json',`{"state": "off"}`
Re: SendToHTTP (GET and POST) with Headers
To make the conversion even easier, you can use the documented 'format 2' use of PostToHTTP, where a regular http:// url can be used.
Alternative HTTP POST with ESPEasy:
Alternative HTTP POST with ESPEasy:
Code: Select all
PostToHTTP,http://192.168.1.25:8123/api/states/light.shellyplus1pm_123456abc123_switch_0,'Authorization: Bearer VERY_LONG_HOME_ASSISTANT_TOKEN_TO_VALORIZE%LF%Content-Type: application/json',`{"state": "off"}`
/Ton (PayPal.me)
Re: SendToHTTP (GET and POST) with Headers
Great, thanks!
Who is online
Users browsing this forum: No registered users and 2 guests