Describe the bug
SharePointService.CreateFile via the @microsoft/power-apps SDK saves corrupted or non-binary file content to SharePoint when uploading images. The file is not openable by any image viewer.
Steps to Reproduce
try upload a photos using CreateFile(dataset: string, folderPath: string, name: string, body: string, queryParametersSingleEncoded?: boolean) where no matter what passed into the body parameters it will always end up corrupted, becoming pure text value
Expected behavior
A valid binary image file (JPEG/PNG) is saved to the target SharePoint document library folder and is openable by any image viewer.
Actual behavior
The uploaded file contains corrupted content. Three variations were observed depending on how the body parameter was prepared:
Body passed to CreateFile |
File content saved to SharePoint |
JSON.stringify({ $content-type, $content }) |
"{\"$content-type\":\"image/png\",\"$content\":\"iVB...\"}" — double-serialised JSON string including outer quotes |
Plain object { $content-type, $content } |
{"$content-type":"image/png","$content":"iVB..."} — JSON envelope object stored as text |
| Raw base64 string |
"iVBORw0KGgo..." — base64 ASCII text stored instead of binary bytes |
In all cases the connector operation CreateFile stores text in the file rather than decoding to binary bytes.
Screenshots or Error Messages
you wont need a screenshot to understand this
Environment information
- Framework / build tool: React 19, Vite 7, TypeScript (strict)
- SDK:
@microsoft/power-apps (Power Apps Code App)
- Connection: SharePoint Online connector (
shared_sharepointonline)
- Operation:
SharePointService.CreateFile(dataset, folderPath, name, body)
- Schema:
body is declared "in": "body", "format": "binary", "type": "string" in the connector OpenAPI schema
Additional context
Root cause traced through SDK source:
ConnectorDataOperationExecutor._buildOperationBodyParam calls JSON.stringify(params[bodyParam.name]) on the body value regardless of the parameter's format field
- The result is passed to
retrieveDataAsync, which wraps it in new Blob([body], { type: 'application/json' }) and sends to the Power Platform gateway
- The gateway forwards the JSON-encoded string body to the SharePoint REST API endpoint (
POST /{connectionId}/datasets/{dataset}/files)
- SharePoint stores the received text payload verbatim instead of binary image bytes
The SDK does not special-case format: binary body parameters in connector operations — it always JSON-serialises them. A native binary/octet-stream passthrough path (uploadDataAsync) exists in runtimeDataClient but is only wired up for Dataverse file column uploads, not connector operations.
Describe the bug
SharePointService.CreateFilevia the@microsoft/power-appsSDK saves corrupted or non-binary file content to SharePoint when uploading images. The file is not openable by any image viewer.Steps to Reproduce
try upload a photos using CreateFile(dataset: string, folderPath: string, name: string, body: string, queryParametersSingleEncoded?: boolean) where no matter what passed into the body parameters it will always end up corrupted, becoming pure text value
Expected behavior
A valid binary image file (JPEG/PNG) is saved to the target SharePoint document library folder and is openable by any image viewer.
Actual behavior
The uploaded file contains corrupted content. Three variations were observed depending on how the
bodyparameter was prepared:CreateFileJSON.stringify({ $content-type, $content })"{\"$content-type\":\"image/png\",\"$content\":\"iVB...\"}"— double-serialised JSON string including outer quotes{ $content-type, $content }{"$content-type":"image/png","$content":"iVB..."}— JSON envelope object stored as text"iVBORw0KGgo..."— base64 ASCII text stored instead of binary bytesIn all cases the connector operation
CreateFilestores text in the file rather than decoding to binary bytes.Screenshots or Error Messages
you wont need a screenshot to understand this
Environment information
@microsoft/power-apps(Power Apps Code App)shared_sharepointonline)SharePointService.CreateFile(dataset, folderPath, name, body)bodyis declared"in": "body","format": "binary","type": "string"in the connector OpenAPI schemaAdditional context
Root cause traced through SDK source:
ConnectorDataOperationExecutor._buildOperationBodyParamcallsJSON.stringify(params[bodyParam.name])on the body value regardless of the parameter'sformatfieldretrieveDataAsync, which wraps it innew Blob([body], { type: 'application/json' })and sends to the Power Platform gatewayPOST /{connectionId}/datasets/{dataset}/files)The SDK does not special-case
format: binarybody parameters in connector operations — it always JSON-serialises them. A native binary/octet-stream passthrough path (uploadDataAsync) exists inruntimeDataClientbut is only wired up for Dataverse file column uploads, not connector operations.