E9.2 Append data into an array

buster27

Member
Hello,

Here is my problem.
I have an orchestration where I get data from a REST API. The output is an array with multiple rows.
At the end I need to create a CSV file with this data which is ok.

But before that I need to add more information related to each row from the array before creating the CSV file.
I will get the data from another API.

1. Array created with multiple rows as a result of an API
2. Run another API to grab additional information of each row using the Iterate over function
3. Then in the output, how to associate the addtional data from (#2) into the array from (#1) so as a next step I can create my CSV file with all info.

I hope my request is clear enough.

Regards
Franck
 
Hi Franck,

If the REST API is returning an array of data in JSON format, and you are on tools release 9.2.5.2 or higher, you should be able to return the array just by configuring the output. You can then iterate over that array to call your second API. The challenge with the second api call is that you will get an array of individual responses that you cannot directly access until you get to the manipulate output part of your orchestration. So I would pass the first array into an another orchestration, iterate through the array and call the second api, and then return the results. You can then pass the raw output of the first API call, and the output of the sub orchestration into a custom request to combine the two into one csv file. In the custom request you can parse the json and iterate through the first API's array, and pick out what you need from the second API array. There should be a one to one correlation between them.

Kevin
 
Hi Kevin,
Thank you for your idea.
In fact I am trying to do something very close to your idea but Iget stuck when trying to iterate the arry in the sub orchestration.
I defined an array an an input parameter of the sub orchestration but inside the sub orchestratation when I try to map my API input variable, I can find the variable as the iterate over option but then there is no variable available to map my input parameter of the API.
It looks like I am missing something to properly pass the Array down the Orchestration to the API call.

Thanks
Franck
 
just to add more information, I noticed when I declare an array an input parameter of my orchestration then when I call the orchestration and try to map
the input parameter, the one realted to the array is name "jde__object".
I wonder whether or not. this is the source of my problem.

Any help would be welcome.

Franck
 
hey franck, wondering if you managed to get this working.
i'm also struggling with the same issue, managed to use groovy to update the array (string) but when i pass it into the 2nd orchestration, i'm able to map the array (string) into jde__object (array) and there are no error messages.
however, the response reads... GridData: []
 
I'm telling you, use chatgpt. It is your friend for groovy scripting without the drudgery of googling, finding something, tweaking it, trying it out, repeat. ChatGPT in my scriptwriting workflow is cutting probably 80% out of each script dev time.

Getting what you want out of a GPT is going to be a skill as important as googling, best get a move-on :)

I've learned more in a short time from reading and digesting chatgpt groovy suggestions in 2 months than I have doing everything "by hand" the last 16 months.
 
Last edited:
Back
Top