web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Upload File to SharePo...
Power Apps
Suggested Answer

Upload File to SharePoint Document Library Code Apps Groups or EntraID Connector

(1) ShareShare
ReportReport
Posted on by 8
I am able to upload a file directly to SharePoint from a canvas app using either the Office365Groups connector.

This works fine in Canvas app. But the exact same request fails in CodeApps.
 
Office365Groups.HttpRequest(
            "https://graph.microsoft.com/v1.0/sites/" & nfDocumentSiteId & "/drives/" & nfDocumentDriveId & "/root:/" & Last(
                Split(
                    ctxDocumentPath,
                    "WISP Documents/"
                )
            ).Value & Concatenate(
                GUID(),
                ".jpeg"
            ) & ":/content",
            "PUT",
            Self.Media
        )
 
the above works perfectly and this is the request



However I cannot replicate this in PowerApps Code apps using the same connector (same id) my files are corrupted.

I have tired every permutation of content/content-type in body, in header.
 
Anyone who can get this working that would be great, also although the large file upload option works in dev, its blocked in production as the published power app cannot acess teh sharepoint endpoint directly.
I have the same question (0)
  • Suggested answer
    11manish Profile Picture
    2,730 on at
    Since the upload succeeds but the resulting file is corrupted, the most likely root cause is that the Code App is sending encoded content rather than the raw
     
    binary stream required by the Microsoft Graph /content endpoint.
     
    The first thing I would verify is the actual payload being sent. If the Code App cannot reliably transmit raw binary data in production, the recommended
     
    architecture is:
     
    Code App  ->  Power Automate (or Azure Function) -> Microsoft Graph / SharePoint
     
    This approach avoids binary serialization issues, works consistently across environments, and is currently the most supportable pattern for file uploads from Code
     
    Apps.
  • Suggested answer
    Valantis Profile Picture
    6,184 on at
     
    The corruption happens because Code Apps serialize binary content differently than Canvas Apps when passing it through connectors.
    The Graph /content PUT endpoint expects raw binary and Code Apps can't reliably deliver that directly.

    The confirmed working pattern: expose the file from the Code App as base64, pass it to a Power Automate flow via the Power Apps connector, decode it in the flow using dataUriToBinary() or base64ToBinary(), and upload to SharePoint using the SharePoint connector Create file action or directly via Graph.

    This also solves your production issue where the published app can't reach the SharePoint endpoint directly the flow runs under its own connection credentials and doesn't require direct browser access to SharePoint.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 404

#2
timl Profile Picture

timl 344 Super User 2026 Season 1

#3
WarrenBelz Profile Picture

WarrenBelz 320 Most Valuable Professional

Last 30 days Overall leaderboard