Hello!
I had fine-working rule with sending a http post request with content, but now it seems that I also need to send a header with authoriation.
In docs (https://www.openhab.org/docs/configuration/actions.html) I found that you can send header also:
sendHttpPutRequest(String url, String contentType, String content, Map<String, String> headers, int timeout)
and an example:
val headers = newHashMap("Cache-control" -> "no-cache")
val output = sendHttpGetRequest("https://example.com/?id=1", headers, 1000)
Unfortunately, when I’m trying to send it, got errors. My rule:
var url_light="some url"
var content
var headers = newHashMap("Integration" -> "true", "Authorization" -> "Bearer xxx")
content='{ "some content": "value", "some content":"value2"}'
sendHttpPostRequest(url_light, "application/json", content, headers, 1000)
And the error from logs:
2020-03-12 07:12:00.082 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Status send': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.HTTP.sendHttpPostRequest(java.lang.String,java.lang.String,java.lang.String,int) on instance: null
It seems like docs are false or I’m doing something wrong. In addition I can say, that without headers all was working fine. Any advice?