cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User III
Dual Super User III

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

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!

View solution in original post

5 REPLIES 5
Highlighted
Dual Super User III
Dual Super User III

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

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?
 
 
Highlighted
Frequent Visitor

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

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

Highlighted
Dual Super User III
Dual Super User III

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

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!

View solution in original post

Highlighted
Dual Super User III
Dual Super User III

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

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!

Highlighted
Regular Visitor

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

Thanks @yashag2255 for your comment 

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

This solved my problem!  

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (8,585)