Exec-Binding sending a curl

Hey,
I want to send, a working curl command, with exec. The problem seems the double quotes. I tried:

Thing exec:command:Test  [command="curl -X PUT http://192.168.178.42:51500/characteristics --header "Content-Type:Application/json" --header "authorization: 031-45-154" --data "{ \"characteristics\": [{ \"aid\": 20, \"iid\": 10, \"value\": 0}] }", autorun=true]
 

I´m getting error
2022-05-25 22:36:04.622 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘Neutstart.things’ has errors, therefore ignoring it: [11,102]: missing ‘]’ at ‘Content-Type’

[11,126]: mismatched input ‘/’ expecting ‘:’

[11,127]: no viable alternative at input ‘json’

[11,168]: mismatched input ‘" --data "’ expecting ‘:’

[11,180]: mismatched input ‘’ expecting ‘}’

[11,249]: no viable alternative at input ‘autorun’

Can someone help me?
Thx joe

You either need to escape the double quotes inside the outer quotes around the whole command, or you need to use single quotes on the outside instead of double quotes.

1 Like

Thanks for your answer. I tried to make single quotes outside.

Thing exec:command:Test  [command='curl -X PUT http://192.168.178.42:51500/characteristics --header "Content-Type:Application/json" --header "authorization: 031-45-154" --data "{ \"characteristics\": [{ \"aid\": 20, \"iid\": 10, \"value\": 0}]', autorun=true]

getting following error:
Configuration model ‘Neutstart.things’ has errors, therefore ignoring it: [11,35]: Character array is missing “e” notation exponential mark.

Looking into the posted command double quotes at the end of --data part seems to be missing.

In case you have the command working on the command line I would wrap it into a shell script and just call that shell script as command. You do not need to worry about escaping the single/double quotes then as long as you already have a working command line.