Using groovy to set substitution variables for non admin users
I've written a groovy script to set substitution variable values using the standard method: operation.application.setSubstitutionVariableValue()
This works fine for Admins but the end users are power users and this operation doesn't work for them due to access rights restrictions despite having provided power user access to the rulescript file but this hasn't made a difference.
I've explored the option to use REST API to set the variable and I've got the following JSON to work via postman without any issues:
However, I'm having difficulty, replicating this in groovy
The approach I've taken is to recreate the payload above as a JSONObject then pass it into the request, using a connection that has been created using an admin account.