- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2025 10:36 AM
hi , I am working with API and I get my response content as shown below .. how do i use script in Action flow designer to convert to Array of objects ?
[
{
"transactionId": 11,
"typeOfRequest": "Add",
"priority": 0,
"employeeNumber": 121
},
{
"transactionId": 12,
"typeOfRequest": "Cancel",
"priority": 0,
"employeeNumber": 122
},
{
"transactionId": 13,
"typeOfRequest": "Cancel",
"priority": 0,
"employeeNumber": 1111
}]
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2025 12:02 PM - edited ‎06-04-2025 12:03 PM
This should be working based on my testing with your provided JSON example.
I think the issue is in your script. You have "outputs.requests = parsedArray," but according to your screenshot, your output variable is named "parsedarray. You script should look like this instead:
(function execute(inputs, outputs) {
var parsedArray = JSON.parse(inputs.ResponseContentString);
outputs.parsedarray = parsedArray; // The name of the variable for "outputs.<name>" should match your step outputs exactly.
})(inputs, outputs);
It might be useful to use more distinct names for your variables and outputs as that might be causing a little confusion. So instead of parsedarray for your step output, maybe something more like Employee Requests [employee_requests].
See attached for examples of what I tested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2025 01:35 PM
Of course! Glad that solved the issue.