Send HTTP PUT request with headers and body and check response

I have a working script that uses curl to request the state of a charging station and act on the response. I want to move that task to homey. First here is the working curl command line:

curl -o - -f -s -X POST -H "Accept: applicion/json, text/plain, */*" -H "Content-Type: application/json;charset=utf-8" -H "O
rigin: https://oebb.smatrics.com" -H "DNT: 1" -H "Referer: https://oebb.smatrics.com/de/" -H "Sec-Fetch-Dest: empty" -H "Sec-Fetch-Mode: cors" -H "Sec-Fetc
h-Site: same-origin" -d '{"evseIds":["AT*SMA*EAT0301891*001AC"]}' "https://oebb.smatrics.com/de/map/poi-status"

The return from the server looks like this:

{"AT*SMA*EAT0301891*001AC":"OCCUPIED"}

And here is my try to recreate that request in Homey:

I copied all the headers and the body directly from the script to Homey. I added all the headers separated with Shift-Enter. The request comes from the same network. The curl options “-f” and “-s” can be removed without any change in response. The manual for the “-d” option from curl reads as:

(HTTP MQTT) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded.

The content type is obviously overriden by the headers in the curl-request.

No matter what I try, I always receive a “403” in Homey. I would be thanksful for any hints or ideas.

Looks like the Logic “Make HTTP request” card is broken, it cuts off header lines after the second colon which mangles the Referer header. Reported on Slack, but it’ll require a firmware update to fix it :roll_eyes:

1 Like

Thanks for the info. I will then wait for a fix.

Just wanted to report back: this works now. Thanks for the fix!
grafik

1 Like