What is your goal?
My goal is to retrieve product stock quantities from an external API.
To do this, I first retrieve a list of products, extract their IDs, and then pass those IDs to another endpoint that returns stock information.
The stock endpoint requires the parameter idProduct formatted exactly as a JSON array of strings like this:
["ID_1","ID_2","ID_3"]
This list must be passed as a query parameter (idProduct) in an HTTP request to an API endpoint that requires a JSON array of product IDs.
The IDs come from a previous HTTP module that returns a list of products.
What is the problem & what have you tried?
The API returns a list of products with the structure:
data.products[].id
Example response:
"data": {
"products": [
{ "id": "c0999f42-af56-4960-bff9-394683763929" },
{ "id": "2c10f60f-7113-4085-a679-8acc3670c569" }
]
}
}
I need to extract only the IDs and build the following string:
["c0999f42-af56-4960-bff9-394683763929","2c10f60f-7113-4085-a679-8acc3670c569"]
I attempted:
{{ "[" & "\"" & join(6.data.products[].id ; "\",\"" ) & "\"" & "]" }}- map(data.products; βidβ)
- Array Aggregator
- concatenation with β[β & join(β¦) & β]β
- i also tried using Array Iterator and Array Aggregator the separate only the ID but i donβt know now how to concatenate the id into a string in that form.
but Make either:
- generates invalid IML errors
- outputs nested arrays
- or sends the formula as plain text instead of evaluating it.
The API only accepts this exact JSON array format for the idProduct parameter.
I just need to build this exact string of IDs to make an API call.
In the screenshot you can see the last attempt im trying to use, in the last HTTP module there is the API call that i need to use.
