Hello
I try to figure if there is a way to use custom IML function in body.
{
// Request to API endpoint.
"url": "/CUSTOMERS", // Relative to base URL
"method": "POST",
"headers": { }, // Additional HTTP headers
"qs": { }, // Query string
"body": "{{arrayToObject({{parameters.labels}})}}",
"response": {
"error": {
"type": "RuntimeError",
"message": "[{{statusCode}}] {{body.error.message}}",
"400": {
"type": "DataError",
"message": "[{{statusCode}}] {{body.error.message}}"
},
"500": {
"type": "ConnectionError",
"message": "[{{statusCode}}] {{body.error.message}}"
}
},
"output": "{{body}}"
}
}
I’m getting errors
the IML function:
function arrayToObject(arr) {
return arr.reduce((obj, item) => {
obj[item.column] = item.value;
return obj;
}, {});
}
I need to transform this:
[
{
"value": "3",
"column": "CUSTNAME"
},
{
"value": "2",
"column": "STATDES"
},
{
"value": "1",
"column": "NSFLAG"
}
]
to this:
{
"CUSTNAME": "3",
"STATDES": "2",
"NSFLAG": "1"
}
In my environment its works,
any ideas guys?
Thank you in advance,
Leon