Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Assign JSON array to gallery not working when assigning a variable

(0) ShareShare
ReportReport
Posted on by 6

I'm creating the JSON array in a variable and then including that in the response body. (substring is just to strip the final line break and comma, cause that append is in a loop)

 

PColley_0-1661992746357.png

 

If I show that 'galleryItems' variable (including the substring) in a label, then copy and paste the data into the array as raw data - the gallery populates as expected.

 

PColley_1-1661992896590.pngPColley_2-1661992965874.png

 

However, when I assign the exact same var to be the array in the JSON the gallery table shows as empty. Any ideas about what I'm missing?

 

With raw data:

PColley_3-1661993150868.png

 

With the variable:

PColley_4-1661993227767.png

 

Edit. just in case it helps this is the schema for the response action:

{
 "type": "object",
 "properties": {
 "json": {
 "type": "string"
 },
 "responseCode": {
 "type": "string"
 },
 "galleryItems": {
 "type": "array",
 "items": {
 "type": "object",
 "properties": {
 "fileName": {
 "type": "string"
 },
 "fileUrl": {
 "type": "string"
 }
 },
 "required": [
 "fileName",
 "fileUrl"
 ]
 }
 }
 }
}
  • Pstork1 Profile Picture
    65,906 Most Valuable Professional on at
    Re: Assign JSON array to gallery not working when assigning a variable

    Sorry I missed the square brackets.  Yes you would need to remove that also.  You were treating the JSON array as though it were string data, but if you use an array variable its already in JSON array format internally so no string manipulation is needed.

  • PColley Profile Picture
    6 on at
    Re: Assign JSON array to gallery not working when assigning a variable

    Thanks so much Paul, only other thing was I had to remove the square brackets from my response body now that I've updated that variable to be an array as they're already included.

     

    Everything you suggested makes perfect sense I was just burned out on debugging I suppose and a little green to Power Apps. Really appreciate your response and all your other responses to questions I have used along the way.

  • Verified answer
    Pstork1 Profile Picture
    65,906 Most Valuable Professional on at
    Re: Assign JSON array to gallery not working when assigning a variable

    Remove the comma from the end of the object in the Append to array statement and then skip using the substring.  Append to Array will automatically supply the commas between the objects you are appending so you don't need to supply them and then don't need to strip the last one off.  Make sure the variable type is actually array and that you are using the append to array action, not append to string.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow