"Incompatible type. The 'file.contentBytes' column in the data source you're updating expects a 'Blob' type and you're using a 'Error' type." That error comes up in the Power Apps community forum again and again, and it showed up in another thread this week. Someone wants to send a file from a canvas app to Power Automate, usually to drop it in a SharePoint library. They follow a video, and the formula won't even save.
The fix is easy once you know what the flow expects. A File input on the PowerApps (V2) trigger takes a record with two fields, name and contentBytes, and the value you put in contentBytes has to be something Power Apps recognises as a file. In this post I walk through the whole round trip: the trigger, the SharePoint action, the Run formula, and the checks I'd do when it breaks.

How it works
The original PowerApps trigger can only take text that it asks for with "Ask in Power Apps". The PowerApps (V2) trigger lets you define typed inputs instead, and one of the input types is File. When you add a File input and connect the flow to your app, the flow's Run function expects a record for it in this shape:
{
file: {
name: "NewInspectionReport.pdf",
contentBytes: PDF(InspectionDetails)
}
}
That's the exact shape Microsoft uses in the PDF function article, where a generated PDF goes to a flow and lands in a document library. The mixed-reality photo article does the same thing with a photo, using {file: {name: GUID() & ".png", contentBytes: ThisItem.ImageURI}}.
On the flow side, both values come out of the trigger body:
- triggerBody()?['file']?['name'] is the file name.
- triggerBody()['file']['contentBytes'] is the file content. This is the same value you get by picking the File Content dynamic content under PowerApps (V2).
The Blob vs Error message is Power Apps type-checking the record before anything runs. It's telling you that the expression in contentBytes doesn't evaluate to a file. The flow isn't involved yet. The problem is on the app side.
Prerequisites
- A canvas app that you can edit in Power Apps Studio, with the Power Automate pane (it's on by default).
- A SharePoint document library where you have permission to add files. Any connector action that accepts file content works the same way, but I'll use SharePoint Create file here.
- Something in the app that produces a file. In this walkthrough that's the PDF function. It's experimental, so turn it on first in Settings > Upcoming features > Experimental > PDF function. Other sources are covered further down.
Step 1: Create the flow with a File input
- In Power Apps Studio, open the Power Automate pane and select Create new flow > Create from blank.
- Delete the default PowerApps trigger and add PowerApps (V2) instead.
- Select Add an input and choose File.
- If you also want the app to pass a file name or a record number, add a Text or Number input as well.
Step 2: Save the file to SharePoint
Add the SharePoint Create file action and fill it in:
- Site Address: your site.
- Folder Path: the document library or folder.
- File Name: the expression below, added through the expression editor (fx).
- File Content: the second expression, or the File Content dynamic content from the trigger.
triggerBody()?['file']?['name']
triggerBody()['file']['contentBytes']
Add them as expressions. If you paste triggerBody()?['file']?['name'] into the field as plain text, the flow saves fine and every file gets that literal text as its name. One of the replies in this week's thread had spotted exactly that in the asker's flow.
Save the flow and close the editor. It shows up in the Power Automate pane under the app.
Step 3: Call the flow from a button
Here's Microsoft's formula from the PDF article, for a flow with a Text input plus a File input:
'PowerAppV2->Createfile'.Run(
"NewInspectionReport.pdf",
{
file: {
name: "NewInspectionReport.pdf",
contentBytes: PDF(InspectionDetails)
}
}
);
Notice the text input goes in first as a plain argument and the file goes inside a record. The order and shape depend on the inputs you defined in Step 1. Type .Run( and follow the parameters Power Apps shows you in the formula bar instead of copying a formula from a different flow.
I'd also guard the call so the flow never runs without a file. That's what the asker in the forum thread was already doing with IsEmpty, and it's a good habit:
If(
IsEmpty(Attachments1.Attachments),
Notify("Attach a file first.", NotificationType.Warning),
'PowerAppV2->Createfile'.Run(
{
file: {
name: First(Attachments1.Attachments).Name,
contentBytes: First(Attachments1.Attachments).Value
}
}
)
)
Where the file comes from
The flow doesn't care where the file comes from, as long as contentBytes gets a real file value. These are the sources I see most often:
- PDF function: PDF(ScreenOrContainer) returns the file directly. It's documented with a PowerApps (V2) flow, so it's the most reliable starting point.
- Mixed-reality photos: ThisItem.ImageURI in a gallery over the captured photos, also documented with a V2 flow.
- Add picture: the control's Media output holds the selected image. Learn documents it for collections and Patch.
- Attachments: each file in the control's Attachments output has a Name and a Value. The modern Attachments control article (the control is still preview) uses exactly First(FileUpload1.Attachments).Name and .Value to save to a Dataverse file column.
For the attachments case, Microsoft documents Name and Value for Patch, but I couldn't find any page that documents sending them to a flow. So if contentBytes gets the Error type from an attachments control, the control isn't giving Power Apps a file value it can use there. Two replies in the forum thread suggest switching to the classic Attachments control in a form card, but Learn doesn't confirm that either. Test it with your control and your data before you build a whole screen around it.
Gotchas
You changed the trigger inputs and the app didn't notice
The app keeps a copy of the flow's definition. If you add, rename or remove a trigger input after adding the flow to the app, the Run signature in the app goes stale. If you edited the flow outside Studio, select ... next to the flow in the Power Automate pane and choose Refresh. Microsoft's troubleshooting guidance for changed inputs, outputs or connections in an app that isn't published yet is to remove the flow from the app and add it back. Then fix the formula to match the new signature.
The app is already published
Changing the inputs of a flow that a live app calls can break that app for everyone. For published apps, Microsoft recommends saving a copy of the flow with Save As, changing the copy, and pointing the new version of the app at it. When everyone's on the new version, turn off the old flow.
Validate what arrives in the flow
Anything Power Apps passes to a flow travels as network traffic and can be changed. Don't trust the incoming file name to build a folder path. Clean it up or build the path in the flow from values you control. Also check the file type if the library has rules about what it accepts.
The error message is about the app, not the flow
When you see Blob vs Error, don't start changing the flow. Look at the expression inside contentBytes and check what that control actually returns. Usually it's the wrong property, the wrong control, or an empty value.
Wrap-up
Sending a file to a flow comes down to one contract: a File input on PowerApps (V2), a {name, contentBytes} record in Run, and the matching triggerBody() expressions in the action. Once that's in place, the only thing left to get right is where the file comes from.
If you're building canvas apps and flows like this, come and swap notes with other practitioners in the 365Connect Community.
Comments
Post a Comment