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 / turn an object of atta...
Power Automate
Answered

turn an object of attachment into an array

(0) ShareShare
ReportReport
Posted on 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?

 



Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    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"
     ]
     }
    }

     

  • GTurkistane Profile Picture
    114 on at

    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\"
    }
    ]

     

  • GTurkistane Profile Picture
    114 on at

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

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    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.

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

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard