- Trigger webhook to make HTTP request
- Iterate an array in the returned payload for a particular value
- Construct a text string to be used for webhook response
- The text string needs to use a counter that starts at and increase by 1 to match the length of the array. When I use indexOf function on the key in the array, I only get the last index.
Include screenshots of
-
scenario
-
HTTP request output
[
{
"statusCode": 201,
"data": {
"mode": "test",
"**shipments**": [
{
"id": "XYZ0123",
"tracking_code": "12345"
},
{
"id": "XYZ1234",
"tracking_code": "54321",
}
],
"id": "order_019eeeeeeeeeeeeeee",
"object": "Order"
},
"fileSize": 123
}
]
I want to construct the following text string:
{
"packages":[
{
"name": "Package 1",
"tracking_url": "https://mycarrier.com/12345"
},
{
"name": "Package 2",
"tracking_url": "https://mycarrier.com/54321"
}
]
}
The name field should be Package 1, Package 2, Package 3 depending on how many objects are in the “shipments” array from HTTP request output. In the iterator, I’m using
"name": "Package indexOf(*140.Data.shipments[].id*:1)"
It returns 9 instead 1 and 2.
How should I get the counter?