[SOLVED] Executecommandline (curl) to Alarmsystem (Lupusec)

I am on OH3 and can succefully set my alarmsystem with curl from a commanline with:

curl -v 'admin:pwd@' -H 'X-Token:MySecretToken'

I know, that space separated commands need to be like:

"curl", "-v", "admin", ...

And I tried many different versions without success:

val execToken = xToken + "'"
answer = executeCommandLine(Duration.ofSeconds(6), "curl", "-v", "'admin:pwd@'", "-H", "'X-Token:" , execToken)


val execCMD = "curl -v 'admin:pwd@' -H 'X-Token:" + execToken
answer = executeCommandLine(Duration.ofSeconds(6), execCMD)

with or without @@ instead of the space.

none of these worked.

because I need to retrieve the token beforehand I cannot “hardcode” it.
Any help is greatly appreciated.

It’s not just a blanket rule where every space separates an argument. In this case the “-v” and “admin” are part of the same argument passed to curl. So treat those as one argument.

"curl", "-v admin", ...

At the end, there isn’t even a space between ‘x-Token:’ and execToken. That one at a minimum should be just one value passed to executeCommandLine.

"-H 'X-Token:"+execToken+"'"

But for retrieving the token this works:

val response = executeCommandLine(Duration.ofSeconds(6), "curl", "-s", "admin:pwd@")

so you mean it should look like this then:

answer = executeCommandLine(Duration.ofSeconds(6), "curl", "-v 'admin:pwd@' -H 'X-Token:"+execToken+"'")

This returns:

curl: option -v admin:pwd@ -H X-Token:MYTOKEN: is unknown

THank you very much @rlkoshak!

This works:

"curl", "-v", "admin:pwd@", "-H", "X-Token:"+xToken)