Skip to main content

Notifications

Power Automate - General Discussion
Answered

collection powerapps to JSon: parse error after creating syntax from sample load

(1) ShareShare
ReportReport
Posted on by 628

Hi, 

Been using for years some code from Youtuber Sean Young for storing attachments from powerapps to sharepoint using a flow.

In a new environment this flow, with the old powerapps trigger, will not be added to the app so I created a new with the new trigger.

The (text) input is a collection containg filenames and file contents as json of attachment control "images".

The resulting text in powerapps that the flow uses looks like this (i substituted ..... for a large part of the file content)

Column base64 will be used for the body of the eventual file.

 

[
{
"Name": "cat.jpeg",
"UniqueName": "86170723-8cat.jpeg",
"base64": "/9j/...../9k="
}
]

 

 

Since the original syntax for parse json from Sean Youngs example is not working (I get InvalidJSON error) I use this text to have powerautomate generate  json syntax

The syntax looks ok but If I enter the same text testing I get the same error

InvalidJSON

The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value cannot be parsed: 'Unexpected character encountered while parsing value: F. Path '', line 0, position 0.'.
 
Below are the syntax in power automate and the code in powerapps.
Anyone an idea

 

 

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

 

 

The flow uses compose, parse jason, apply to each (save file).

In parse Jason I use

 

Powerapps code adapted to my situation:

 

;ClearCollect(
 ColFiles
 ,ShowColumns(
 AddColumns(
 gAttachments.AllItems
 ,base64
 ,With(
 {
 varDemoFromAttachmentcontrol
 :JSON(
 Image4.Image
 ,JSONFormat.IncludeBinaryData
 )
 }
 ,Mid(
 varDemoFromAttachmentcontrol
 ,Find(",",varDemoFromAttachmentcontrol)+1
 ,Len(varDemoFromAttachmentcontrol) - Find(",",varDemoFromAttachmentcontrol)-1 
 )
 )
 ,UniqueName,Left(GUID(),10) & Name 
 ,ThisImage,Image4.Image 
 ) 
 ,base64
 ,Name
 ,UniqueName
 //;"ThisImage"
 )
 ) 

 

I see Sean did some editing of the file content so I also tried the unedited JSON of the attachment control image contents but same result.

  • Verified answer
    HansHeintz Profile Picture
    HansHeintz 628 on at
    Re: collection powerapps to JSon: parse error after creating syntax from sample load

     Never mind I found a later video by Sean on how to deal with the new powerapps trigger v2

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,422

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,711

Leaderboard