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 Platform Community / Forums / Power Automate / I don't want any squar...
Power Automate
Unanswered

I don't want any square brackets "[ ]" around my array in compose Action.. How do I achieve this?

(0) ShareShare
ReportReport
Posted on by 6

Hello!

 

  • I have the following flow, where I compose a new array:

https://i.imgur.com/vZtCm3f.png

 

  • This array needs to be embedded in a specific schema I need to upload via HTTP POST:

https://i.imgur.com/iHPp4fh.png

 

  • Now, when I run the flow there are "[ ]" around the array, which is not allowed in the schema/syntax of the HTTP POST... Therefore it's not working:

https://i.imgur.com/Kjq6u8A.png

 

 

How can I embed the array without generating these square brackets -> [ ] around of it?

 

Thanks for every help or tipp!

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Julian1 

     

    The square brackets are coming because your "items" variable is of type array and you are appending an object returned everytime from the Apply to each look.
     
    Looking at your screenshots and the logic, you are trying to pass array of multiple objects as data to HTTP request. If this contains multiple objects, this needs to be binded in an array, otherwise it will not be a valid JSON.
     
    Can you share more details on the Schema of Request Body that you are trying to pass to the POST request?
     
     
  • Julian1 Profile Picture
    6 on at

    Hi Yashag,

    Thanks for your reply.

     

    Here is an overview over my flow:

     

     

    The HTTP POST in the end needs to be in this schema:
    ... the "data" : { } is gonna be filled with the Output of "Compose Task JSON" and is an array (Repeatgroup which is repeated 1 to 10 times)

     

     

    I hope this helps? 

    Thansk in advance

  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Julian1 

     

    I was referring to the same flow that you added as attachments in this post.
     
    In the get rows excel action, you are parsing some json and composing another object. But you are not using the output of the Compose Task Json action anywhere. IN the append to array variable you are appending the current item that is the current item from the parse json action. 
     
    As per your flow, you are getting table data from excel sheet. Can you please confirm if this is getting all the rows or just getting one row based on some filters?
     
    You have an apply to each loop with iterates over the array of elements returned from excel (This could be one row or multiple rows), now you are parsing the child items as JSON and appending it to array, which would create a number of objects in the same array.
     
    If you are getting multiple records through the above steps, then your "items" array will look something like:
     
    [
    {
    "Email":"abc@xyz.com",
    "Art":"testart",
    ...
    "Ausfuehrende_Firma":"Test123"
    },
    {
    "Email":"def@xyz.com",
    "Art":"testart1",
    ...
    "Ausfuehrende_Firma":"Test1234"
    }
    ]
     
    This will create a type mismatch if we try to remove the array square brackets because as per the request format, your data attribute is expecting a single object but in this case, you may have multiple objects returned.
     
     
    In case you want to refer to specific array index value, you can select that value as:
    variables('items')[0] or variables('items')[1]. 
     
    Hope this Helps!
     
    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Julian1 

     

    Were you able to resolve this? 

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • Mld9 Profile Picture
    22 on at

    Thanks @yashag2255 for your comment 

    variables('items')[0] or variables('items')[1]. 

    This solved my problem!  

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard