Hello openHAB Community!
I’m currently running openHAB 3.4.1 inside a Docker container on my Synology. I’m facing an issue with my automation rule written in JavaScript, located at .../conf/automation/js/some_rule.js
.
When I try to update my Controme Gateway using the httpPostRequest
method from this rule, it doesn’t behave as expected.
curl "http://192.168.178.81/m_setup/1/hardware/gwedit/3/" \
-X POST \
-H "Cookie: csrftoken=OBFUSCATED; sessionid=OBFUSCATED" \
--data-raw "csrfmiddlewaretoken=OBFUSCATED&...rest_of_the_data..."
To replicate this in my openHAB rule, I’m using the following:
let url = "http://192.168.178.81/m_setup/1/hardware/gwedit/3/";
let contentType = "application/x-www-form-urlencoded";
let content = /*structured_content_data_here*/;
let headers = {
"Cookie": "csrftoken=OBFUSCATED; sessionid=OBFUSCATED"
};
let timeout = 5000; // Just as an example
actions.HTTP.sendHttpPostRequest(url, contentType, content, headers, timeout);
Even after ensuring the content is correctly formatted and URL-encoded, and headers are set up as in the curl
command, the httpPostRequest
fails to mirror the effect of the curl
command.
Has anyone encountered a similar issue, especially in the context of JavaScript rules in openHAB? Any pointers or guidance would be greatly appreciated!
Thank you for your time and assistance!
Warm regards,
Frank