web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Create a nested array

(0) ShareShare
ReportReport
Posted on by 23

Hi everyone, 

I need to create a JSON array to send to a REST API, the format the API expects is like this: 

Dubbel_Lars_0-1701848262735.png

I have managed to create the array from my data with a select element, after that i have used another select element and now my result looks like this

Dubbel_Lars_1-1701848292702.png

The only thing remaining is adding to each array element the element and field tags so the API i am sending to understands it, but after many hours of trying i cannot find an option to do this. Can anyone help me? 

Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    on at

    Hi , @Dubbel_Lars 

    According to your expected json format , it seems it is not a invalid json. You have two same keys in your json format:

    vyueyunmsft_0-1701849119972.png

    vyueyunmsft_2-1701849222739.png

     

    Can you check if your expected result is like this:

    vyueyunmsft_1-1701849158335.png

     

     

     

    Best Regards,

    Yueyun Zhang

  • Dubbel_Lars Profile Picture
    23 on at

    Ah, i did not know that keys needed to be unique. I am new with JSON and the API accepted my first result so because of that i thought i was doing the correct thing. Thanks for this advice! 

     

    The format you are sharing does not work, but i did it like this and that gives a valid JSON result and is working in the API i am sending to.

    Dubbel_Lars_0-1701850316770.png

    The only question remains is, how to do this in Powerautomate? The result that i got in Powerautomate so for as i mentioned earlier is this:

    Dubbel_Lars_1-1701850483737.png

     

  • v-yueyun-msft Profile Picture
    on at

    Hi , @Dubbel_Lars 

    For your api , can trigger two times with twice json:

     

     

    {
     "KnContact": {
     "Element": {
     "Fields": {
     "BcCoOga": "1000456",
     "BcCoPer": "1002119",
     "CdId": "1654",
     "Vikc": "PRS",
     "TeNr": "0751234567",
     "NbNr": "0621345678"
     }
     }
     }
    }
    {
     "KnContact": {
     "Element": {
     "Fields": {
     "BcCoOga": "1000455",
     "BcCoPer": "1002118",
     "CdId": "1652",
     "Vikc": "PRS",
     "TeNr": "0751234567",
     "NbNr": "0621345678"
     }
     }
     }
    }

     

     

    Or you need put it just in one json object?

    As in Power Automate , if i give this json , the result is as follows:

    vyueyunmsft_0-1701851638522.png

     



     

    Best Regards,

    Yueyun Zhang

  • Dubbel_Lars Profile Picture
    23 on at

    I want to put it in one JSON object, the way i am trying to achieve this is like this:

    Dubbel_Lars_0-1701854056555.png

    Dubbel_Lars_1-1701854085760.png

    Dubbel_Lars_2-1701854115386.png

    And this gives me this output: 

    Dubbel_Lars_3-1701854143774.png

    So what do i need to do in my flow to get to this result:

    Dubbel_Lars_4-1701854202068.png

     

  • Verified answer
    v-yueyun-msft Profile Picture
    on at

    Hi , @Dubbel_Lars 

    Thanks for your detailed description. This is my test flow and the result :

    vyueyunmsft_0-1701855172442.png

    (1)My compose is the test data :

    vyueyunmsft_1-1701855194337.png

    (2)The initialize variable action:

    vyueyunmsft_2-1701855213076.png

    (3)The Apply to each action:

    vyueyunmsft_3-1701855336074.png

    range(0,length(outputs('Compose')?['KnContact']))
    outputs('Compose')?['KnContact']?[items('Apply_to_each')]
    if( equals(items('Apply_to_each'),0) ,'',items('Apply_to_each'))
    body('Select_2')?[0]
     
    (3)The last action:
    vyueyunmsft_4-1701855373560.png

     

    Best Regards,

    Yueyun Zhang

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard