[SOLVED] Exec Curl Not Working

Trying to perform a curl from rules but won’t work, works fine on Cli and have tried so many different ways, help please…
(Credentials are not real)

executeCommandLine("curl -X POST
https://publicapi.lightwaverf.com/v1/feature/5c7d64783c570522afb151b5-24-3157331848+1
-H ‘Authorization: bearer eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI4YjUzMTZjY2ExZGRjZmNjYTBjMiIsImlzcyI6Imh0dHBzOi8vYXV0aC5saWdodHdhdmVyZi5jb20iLCJzdWIiOiJmMzRjN2I4My0yM2I3LTQ1MTEtODQxYy1jOTNhM2MxMDBmZGEiLCJhdWQiOiI0OWQ2N2NmZC00YzVyNi04NWFjMzRhYmY2ODAiLCJleHAiOjE1NTYzOTM5NzYsImlhdCI6MTU1NjM1Nzk3Niwic2NvcGUiOi.g5LjiSZBwb73qIeJzzoMjEGMAWWJiogLY8lLBaGdRw_u3_TTE4F5luBLi-K_dIv0cTh_NvoihXh8HP-4cwN8T4hbdJe7t5n2WSG5P598Nlf1XBZoypKMlwnCkXHVk9oDz7gUkUBs6NHUC2K2n1wzmMnqduTPEtRSXfb1RglANbkQj8GSf8PDnhnt6_4MOPJGlyAFMeKOGXAvETtiubHI3J-DaHUwV7twJLHcq9ig-QVo8CPHjRIFK3k0hBnmY3ECiVi2ac0vP1Re9peGIzYAjX1vaVX_Pz7fuNqncmAoU9RRDwsSlXKcsnPFYAOi3vSDOSYebGnQenfbSmZ0oOxrQTlYgrIX5fxn-cd2hvnvIdQiEM4RBGsBgdhgQrQgoZ37tJe55cZb0rZhQNP5BFa7K-0IQoT-nYRLbgvT4CXAVLI4fyLjNdykT8G0jRhiMxZhOu3_ni0BD249CLCIoIHHhfTtRv3WxOcILJvYfWV2ArBdCSd9apRzUDSs92k4UgLWX5A-n-Lt4k6NZVfZCMbEsiUH89NGPdeHjXMhfpQNR24LLg6Gh-NPclLHhclgsklEHI3kdsyy3APIrSnyvG65NgTiGarZ3mNrEikdd37Dx4ky2wAy56u1QSUwcuULiBPo-iChmU’
-H 'Content-Type: application/json’
-H ‘cache-control: no-cache’
-d ‘{
“value”: 1
}’ ")

Does the curl command work as expected within a bash script?

After about 12 hours of tinkering with it I finally got it to work, and yes it worked perfect from a script but wanted to use variables so needed it direct in a rule.

Well, it’s possible to use variables through exec binding, too :).

Would you mind posting an example up, say for an exec thing/item it takes the state of an item as part of the url.

Well, see https://www.openhab.org/addons/bindings/exec/#full-example for details:

// "%2$s" will be replace by the input channel, this makes it possible to use one command line with different arguments.
// e.g: "ls" as <YOUR COMMAND> and "-a" or "-l" as additional argument set to the input channel in the rule.
Thing exec:command:yourcommand [ command="<YOUR COMMAND> %2$s", interval=0, autorun=false ]

The simplest way would be to set autorun to “true”, this way openHAB will start the command as soon as the input channel was updated.

Wouldn’t work.
For some reason the binding cannot handle the url that works perfectly with executecommandline.
Spent hours trying all manner of variations and just wouldn’t have it.
Doesnt like @@ for spaces
Doesn’t honor ’ marks
One of my -H has a space in it and it tries to treat it as a host name.

So for instance: -H Authorization:bearer access_token
This will not get accepted at all as there is a space required between bearer and the access token. I’ve tried wrapping in ’ ’ but makes no difference, ive tried putting @@ between and it doesn’t work. i’ve tried wrapping in " and '.
If you know how the binding treats the space and how i need to format it then it would be most helpful.
The output and logInfo doesn’t give me anything helpful, just {message:unauthorised} as it wont accept the token. It would be helpful to see exactly what the binding does to the command before it posts it to the commandline