I have a request to do the following. 1. call end point 1 to return some data (we'll say {a,b,c,d,e,f, x,y,z}). The records a-f get mapped to a SON formated response we'll case 1. 2. for the records x, y and z, call a DIFFERENT end point that returns a different response , get formatted to the same structure as records a-f and then get appended to J1 the results generated by records a-f. The challenge is that both a-f and x-y can have 0-n records. My initial attempt was to use a parallel for each scope but that did not work. I also tried the "lookup" function but that is getting deprecated.
I’ve done something similar in DW 2.0 and the key is not trying to be too clever with parallel scopes. Call endpoint 1 once, split the response into two arrays in DataWeave and always default them to empty so 0 records doesn’t break the flow. Map a-f straight into your target structure.
For x/y/z, loop with a simple For Each, call endpoint 2, and push each response into a list variable. After the loop, normalize both results to the same shape in one final DW and just append the arrays with ++. If endpoint 2 supports bulk requests, even better is to pass all x/y/z in one call and skip the loop entirely. Either way, one final mapping step is much easier and avoids the deprecated lookup pattern.