Want to append the json output of one web activity to array variable in adf ?

Amar Agnihotri 926 Reputation points
2022-06-29T08:17:14.35+00:00

Hi,
I have created a pipeline which is using two web activities for api call and the one outside the until loop and other inside the until loop

This is the pipeline -
215920-image.png

i have declared these variables -
216023-image.png

When i run this pipeline this is the output of first web activity "Get User Activity Data" . the out put is in json format
216041-image.png

and i am storing this output to an array variable "Data"
216024-image.png

Now another web activity inside until loop is also generating output in multiple iterations and i want to append that out put to this array variable "Data" but when i tried to do that i got this error

216007-image.png

It says that an array can not be appended to an array variable

Now when i converted the array output to string and then tried then it got appended to array variable and this is my final output in array variable -

216035-image.png

You can see that the format of the output is badly disturbed due to conversion of Json output to string. Now i have to choices 1) - Go and format the output removing backslashes, space line character , new line characters . 2)- If i could find a way to append array oputput to array variable then i can easily save the output in my storage as json file .

That's why i posted this question. Can anyone help me out achieving the desired output either in csv format or in json file. I am ready to use script task also if i could find any C# script to append two array outputs.

Thanks

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
0 comments No comments
{count} vote

Answer accepted by question author
  1. ShaikMaheer-MSFT 38,631 Reputation points Microsoft Employee Moderator
    2022-06-30T09:50:23.603+00:00

    Hi @Amar Agnihotri ,

    Thank you for posting query in Microsoft Q&A Platform.

    Array variables cannot contain items of type array in Azure data factory. Hence you are seeing that error. Since your converted that array outputs as strings and then tried to store array variable, it worked.

    I am little unclear, what you want to do array storing array values in array variable. From your screenshot of line, I could assume that finally you are converting entire array variable data bask to string and then may be that string you are storing as some value in to some column of file or table. Please correct me If I am wrong.

    If my above understanding is correct, then the approach you tried is also fine, where you taken data as string and appended in to array. Please note, the backslashes which you see usually are escape characters. If in your case if your seeing blackslahes also getting saved in to your file, then try to use replace() to replace unwanted characters with empty and then store it to your file.

    Please check this documentation which explains about who special characters can be replaced which shown in dynamic content editor.

    Hope this helps. Please let us know if any further queries.

    ----
    Please consider hitting Accept Answer button. Accepted answers help community as well.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.