I have a module whichs body is defined like below. But now “values” is added twice. What do i need to change to have not values projected in the first line but only once with the ToCollection conversion below?
"body":{
"{{...}}": "{{parameters}}",
"values": "{{toCollection(parameters.Values;'key';'value')}}"
},
In your current setup, values
is appearing twice because {{...}}: "{{parameters}}"
expands all key-value pairs from parameters
, which includes values
. Then, you’re explicitly adding values
again with toCollection
.
Solution:
To avoid values
appearing twice, exclude it from the initial expansion. Make sure that parameters
doesn’t directly output values
. Instead, define the body like this:
“body”: {
“{{remove(parameters; ‘Values’)}}”: “{{parameters}}”,
“values”: “{{toCollection(parameters.Values;‘key’;‘value’)}}”
}
this returns the error Function ‘remove’ finished with error! ‘{object}’ is not a valid array.
I also tried
“{{…}}”: “{{remove(parameters; ‘Values’)}}",
“values”: "{{toCollection(parameters.Values;“key”;“value”)}}”
same problem
If ‘parameters’ is an object, remove() will error as it only accepts arrays.