Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to append array data to array variable in logic app?

I'm calling API using HTTP connector getting result array data. and used until loop. so every time i will get some records into result array.

Now I want to append all records so that i will those all.

Like 1st time i got 2 records like below and 2nd time 1 then I want to append so that it will be 3 total.

1st iteration result -

"results":[
{"id":"2","name":"t1"},{"id":"3","name":"t4"}
]

2nd iteration result -

"results":[
  {"id":"66","name":"i7"}]

I want to append all data so that final result will be like -

[{"id":"2","name":"t1"},{"id":"3","name":"t4"}, {"id":"66","name":"i7"}]

instead of foreach I tried using append array variable but it throws below error -

its a type of array need to be string to append. enter image description here

I can able to achieve it using foreach but it does not make sense just to add values use foreach instead if we found any way to directly add array it will be great. enter image description here

like image 511
Neo Avatar asked Dec 01 '25 01:12

Neo


2 Answers

You can use JS inline code to implement your requirement. I did some test on my side, post to arrays(result1 and result2) to logic app and compose them using JS : enter image description here

Result :

enter image description here

Please note if you want to use this feature , you should create an integration account and associated with your logic app in "Workflow settings" blade .

like image 162
Md Farid Uddin Kiron Avatar answered Dec 02 '25 17:12

Md Farid Uddin Kiron


The above solution works only if you have integration account. Other simple option - use union function inside compose action to append two array collections:

union(variables('ResponseArray'),body('Response')) enter image description here https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#union

like image 41
Nilesh Sawant Avatar answered Dec 02 '25 16:12

Nilesh Sawant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!