Basically the command works and the request reaches the server and I get the following in the response in the openhab.log
{"fault":{"code":900902,"message":"Missing Credentials","description":"Required OAuth credentials not provided. Make sure your API invocation call has a header: \"Authorization: Bearer ACCESS_TOKEN\""}}
You can clearly see that I am sending the bearer token !
I also put the curl command in a file and I execute it with curl as a script and it also works! But I am not sure if I can pass a variable to an external script
var String json2 = executeCommandLine('curl /etc/openhab2/scripts/curl_script.sh',5000)
Can anybody help ?
Edit: Some more information. I added -v to get more information on what I sent and I see this
After testing I see that it is the spaces in the Authorization header that result in that header being sent within the quotes. But why ? How can I remove those quotes ?
Instead of using spaces to separate arguments you can also use @@. I think the current code is based on the openHAB 1 Exec plugin which also has some documentation about issues with passing arguments. It will not look nice with all those @@ though.
Oh believe me I have tried … with and without @@ and all possible combinations i could think of. In the end I pass the argument I want but it is always within quotes and I do not understand why
The moment I add spaces even in other headers they are put within quotes which I find wrong. In any case my workaround works so I am happy
It would be nice if custom headers like the “Authorization: Bearer XXX” were possible with the normal sendHttpPostRequest script commands. That way you would not have a need for curl with all those issues at all. It would also be platform independent.
I’ve recently discovered that the sendHttpGetRequest also does not support Headers, this is different than what is allowed in a http item definition. For functionality that already exists in a different form I’d think it could be implemented rather directly and would correct many of these curl/exec/script workarounds.