cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Julian1
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
yashag2255
Dual Super User II
Dual Super User II

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
yashag2255
Dual Super User II
Dual Super User II

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?
 
 

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

yashag2255
Dual Super User II
Dual Super User II

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

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!

Thanks @yashag2255 for your comment 

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

This solved my problem!  

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Users online (2,389)