Skip to main content
Community site session details

Community site session details

Session Id : D3hw0+K0/ci7LsoRE/ZnEe
Power Automate - Using Flows
Answered

turn an object of attachment into an array

Like (0) ShareShare
ReportReport
Posted on 25 Dec 2023 12:51:08 by 114

i am receiving multiaple attachment from power apps in the form of a json file, after i receive it, i want to parse it and put it in an array. here is my flow so far:

 

GTurkistane_1-1703508159658.png

 

the json file i recieved has:

[

{

name: "File Name"

contentBytes: "actual file bytes"

},

{

name: "File Name"

contentBytes: "actual file bytes"

},...et

]

 

schema:

 

{
 "type": "object",
 "items": {
 "type": "array",
 "properties": {
 "Name": {
 "type": "string"
 },
 "Value": {
 "type": "string"
 }
 },
 "required": [
 "Name",
 "Value"
 ]
 }
}

 

GTurkistane_2-1703508207194.png

when i reach this step in the flow it gives me the following error:

GTurkistane_3-1703508252881.png

who can i fix this or is there a better method?

 



  • Pstork1 Profile Picture
    67,158 Most Valuable Professional on 26 Dec 2023 at 16:46:33
    Re: turn an object of attachment into an array

    As I pointed out in my message the schema you are applying is incorrect for the JSON you are supplying.  The schema says its an object, but the JSON you display starts with [ which is an array. Could you explain what you are trying to accomplish?  That would help me point you in the right direction.

  • GTurkistane Profile Picture
    114 on 26 Dec 2023 at 07:50:25
    Re: turn an object of attachment into an array

    is there a way to turn an object into an array?

  • GTurkistane Profile Picture
    114 on 26 Dec 2023 at 06:08:17
    Re: turn an object of attachment into an array

    thank for the replay but am getting an error:

    GTurkistane_0-1703570288530.png

    here is the power apps v2 flow:

    GTurkistane_1-1703570489752.png

    its schema:

    {
     "type": "object",
     "properties": {
     "text": {
     "description": "Please enter your input",
     "title": "Input",
     "type": "string",
     "x-ms-content-hint": "TEXT",
     "x-ms-dynamically-added": true
     }
     },
     "required": [
     "text"
     ]
    }

    its output:

    [
    {
    \"contentBytes\":\
    "iVBORw0KGgoAAAANSUhEUgAAAUwAAACYCAMAAAC4aCDgAAAAkFBMVEXaICj////cKzPaGyTgTlTYAADZFR/65ufYAA798PDiY2b+9fbjZmrcNDrZBhXxvL3YAAj30NLZCxjvr7DupqjcJS/YABHiWl7kbnH1ycr++fnpiIv31tf53+Dyvb/rlpneQkjmd3vsm57ngIPqj5LsnqHfRkzvra/mdXndOkDgTFHh...etc (too long to put here)" 
    "name\":\"download.png\"
    },
    
    
    {
    \"contentBytes\":\"/9j/4QA+RXhpZgAASUkqAAgAAAABAJiCAgAZAAAAGgAAAAAAAABFYmVyc29sZSBQaG90b2dyYXBoeSBMTEMAAAAA/+wAEUR1Y2t5AAEABAAAADwAAP/hBYpodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDcuMi1jMDAwIDc5LjFiNjVhNzliNCwgMjAyMi8wNi8xMy0yMjowMTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM...etc (too long to put here)" 
    ,\"name\":\"test-taking-tips.jpg\"
    }
    ]

     

  • Verified answer
    Pstork1 Profile Picture
    67,158 Most Valuable Professional on 25 Dec 2023 at 13:29:12
    Re: turn an object of attachment into an array

    The JSON string you received is already an array.  But the JSON you list in the post has some issues.  The key names need to be in quotes and you are missing commas between the values.  Here's a corrected sample.

    [
    {
    name: "File Name"
    contentBytes: "actual file bytes"
    },
    {
    name: "File Name"
    contentBytes: "actual file bytes"
    }
    ]
    

     

    Once the JSON is correct all you need is to do a Parse JSON with the right Schema. But the schema you are currently showing is incorrect. The second property should be "contentBytes" not "value".  You don't need the step to add it to the array its already an array.  This is the correct schema

    {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "name": {
     "type": "string"
     },
     "contentBytes": {
     "type": "string"
     }
     },
     "required": [
     "name",
     "contentBytes"
     ]
     }
    }

     

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Featured topics

Restore a deleted flow
Loading complete