Hi,
a pretty old thread but this is the same question for my problem.
I want to execute a file based JS Rule and want to handover some parameters.
For me and ChatGPT it wasn’t possible to figure out how I can access the request body.
So direct access of the parameter additionalProp1 like in the linked thread is not possible.
Can somebody help here?
I do not know how to pass arguments through the REST API so I cannot comment whether the curl command is correct. It looks like it might be correct but .
raw all Original contents of the event including data passed from a calling rule N/A
I don’t use file based rules, but raw is the original Java Object passed to the rule without any manipulation by the library. So it will be the same for UI and file based.
2025-12-03 11:53:42.490 [INFO ] [b.automation.jsscripting.rule.toCall] - Type is undefined
2025-12-03 11:53:42.493 [INFO ] [b.automation.jsscripting.rule.toCall] - raw {additionalProp1=foo, additionalProp3=baz, ruleUID=toCall, additionalProp2=bar}
2025-12-03 11:53:42.494 [INFO ] [b.automation.jsscripting.rule.toCall] - raw.additionalProp1 foo
Note that the exact same event Object is now passed into UI based rules from OH 5.1 M1 forward, so this is the exact same thing one would see from a file based rule.
Note: you should always set the id of the rule so it’s both meaningful and doesn’t change every time you edit the file.
You do not mention which version of OH you are on. If it’s before OH 5 the answer may be you can’t do this. Sometime during OH 4’s development adding these passed in arguments were added to the event Object for file based rules. Before that though it was not supported.
ok Openhab version was the trick. I updated my test instance to version 5 M2 and this is working.
I’m still a bit wondering why this functions is not already working in 4 but ok.
Thanks also for the hint with the rule id … was not aware of it. Make it’s a lot more easier to call the rule over rest api …