Hi Wolfgang,
I in fact got my managed switch to mirror the ports on which my Synology and my Controme Miniserver are running to my wireshark PC and got it all up and running. I can see the difference in both calls - curl vs. rule.
It seems that my openhab JavaScripting call of actions.HTTP.sendHttpPostRequest adds a unwanted cookie into the headers hash map.
This is the wireshark recording of the POST triggered by the RULE:
Here you can see the additional cookie entry.
Yet another unwanted and uncalled header entry here is: Accept-Encoding:
Hypertext Transfer Protocol
POST /m_setup/1/hardware/gwedit/3/ HTTP/1.1\r\n
Accept-Encoding: gzip\r\n
User-Agent: Jetty/9.4.46.v20220331\r\n
Cookie: csrftoken=0xyL....cC3I; sessionid=5fw8....iurp\r\n
Cookie pair: csrftoken=0xyL....cC3I
Cookie pair: sessionid=5fw8....iurp
Content-Type: application/x-www-form-urlencoded\r\n
Host: 192.168.178.81\r\n
Cookie: csrftoken=qwOk....V4Hf\r\n
Cookie pair: csrftoken=qwOk....V4Hf
Content-Length: 302\r\n
[Content length: 302]
\r\n
[Full request URI: http://192.168.178.81/m_setup/1/hardware/gwedit/3/]
[HTTP request 1/2]
[Response in frame: 97546]
[Next request in frame: 97550]
File Data: 302 bytes
This is the successfully working CURL call in contrast:
Hypertext Transfer Protocol
POST /m_setup/1/hardware/gwedit/3/ HTTP/1.1\r\n
Host: 192.168.178.81\r\n
User-Agent: curl/7.55.1\r\n
Accept: */*\r\n
Cookie: csrftoken=0xyL....cC3I; sessionid=5fw8....iurp\r\n
Cookie pair: csrftoken=0xyL....cC3I
Cookie pair: sessionid=5fw8....iurp
Content-Length: 302\r\n
[Content length: 302]
Content-Type: application/x-www-form-urlencoded\r\n
\r\n
[Full request URI: http://192.168.178.81/m_setup/1/hardware/gwedit/3/]
[HTTP request 1/1]
[Response in frame: 6472]
File Data: 302 bytes
In my preparation for the JavaScripting call of sendHttpPostRequest I tried to set the cookie value to ‘null’ prior to setting it to my desired value.
// HTTP.sendHttpPostRequest(String url, String contentType, String content, Map<String, String> headers, int timeout)
var url = "http://192.168.178.81/m_setup/1/hardware/gwedit/3/"
var contentType = "application/x-www-form-urlencoded";
var headers = {
"Cookie": null,
"Cookie": "csrftoken=0xyL....cC3I; sessionid=5fw8...iurp"
};
var payload = "csrfmiddlewaretoken=O6vY....9wvN&name=90-b2-e5-05-19-48&description=HKV+DG&out1=21&out2=17&out3=24&out4=7&out5=100&out6=100&out7=100&out8=100&out9=100&out10=100&out11=100&out12=100&out13=100&out14=100&out15=100®elbereich_min=0®elbereich_max=100"
var response = actions.HTTP.sendHttpPostRequest(url, contentType, payload, headers, 40000);
console.info("responseBody: " + response);
I found a Similar Community Topic that refers to the same behaviour of header values being pre set to something unwanted.
It seems I need to upgrade to something past 3.4.3 now. :-/
Any suggestions before I do that?
Cheers
Frank