Power Apps  

How to Power Apps to upload attachments to SharePoint via Microsoft Graph

introduction

Power Apps (Canvas) enables file uploads to SharePoint by using Microsoft Graph APIs. By combining an Attachment control with a Graph PUT request, files can be securely uploaded to a SharePoint document library (Drive), providing a flexible alternative to standard SharePoint connectors

โœ… Power Apps Canvas โ€“ Upload Attachments to SharePoint via Graph

Scenario:

  • Source: Attachment control

  • Target: SharePoint document library

  • Method: Microsoft Graph PUT (simple upload)

  • File size: โ‰ค 4 MB

๐Ÿ”น Working Power Fx Code on Upload button

ForAll(
    AttachmentControl.Attachments As FileAttachment,
    Office365Groups.HttpRequest(
        "https://graph.microsoft.com/v1.0/sites/{SITE-ID}/drives/{DRIVE-ID}/root:/" &
        FileAttachment.Name &
        ":/content",
        "PUT",
        FileAttachment.Value
    )
);

Reset(AttachmentControl);

๐Ÿ”น Add Office365Groups

TinyTake27-01-2026-07-08-24

๐Ÿ”นFlow through to get SiteID

TinyTake27-01-2026-07-12-32TinyTake27-01-2026-07-23-29Screenshot 2026-01-27 184705

๐Ÿ”นFind a SharePoint document library DRIVE ID

Step 1: Open Graph Explorer

๐Ÿ‘‰ https://aka.ms/ge

Step 2: List document libraries (drives)

GET https://graph.microsoft.com/v1.0/sites/{SITE-ID}/drives

Response example:

{
  "value": [
    {
      "id": "b!1sgLgNpL7EC2Hr7BleZb25UIxcUghT1Cg9_fHTLzaLfP4GPK7osMQrEDSvsGBHl-",
      "name": "Documents"
    },
    {
      "id": "b!abc123...",
      "name": "Shared Documents"
    }
  ]
}

๐Ÿ‘‰ The id next to the library name you want = DRIVE ID

Sign in with the same account you use in Power Apps.

๐Ÿ”น Replace These Values

PlaceholderDescription
{SITE-ID}SharePoint Site ID
{DRIVE-ID}Document Library Drive ID
AttachmentControlYour attachment control name

๐Ÿ”น Upload to a Folder

/root:/Folder1/SubFolder2/" & A.Name & ":/content

โš ๏ธ Folder must already exist โ€” Graph wonโ€™t create it.

๐Ÿ” Required Permissions

Your Power Apps connection must include:

  • Files.ReadWrite.All

  • Sites.ReadWrite.All

(Granted automatically via the Office 365 Groups connector, but admin consent may be required.)

โš ๏ธ Important Limits

ItemLimit
File size4 MB max
Upload methodSimple upload only
Folder creationNot supported
Overwrite behaviorReplaces existing file

๐Ÿ”„ For Files Larger Than 4 MB

You must use Upload Sessions:

POST /drive/root:/filename:/createUploadSession

Power Apps cannot do chunked uploads natively, so youโ€™ll need:

  • Power Automate

  • Azure Function

  • Custom API connector

๐Ÿงช Debug Tip

Wrap in IfError() to catch failures:

IfError(
    Office365Groups.HttpRequest(...),
    Notify("Upload failed", NotificationType.Error)
)

Conclusion

  1. Add an Attachment control in the Canvas app.

  2. Get the SharePoint Site ID using Microsoft Graph.

  3. Identify the document library Drive ID.

  4. Build the Graph upload URL using Site ID + Drive ID.

  5. Loop through attachments using ForAll().

  6. Upload each file with a PUT request via Office365Groups.HttpRequest.

  7. Send file content as binary with Content-Type: application/octet-stream.

  8. Ensure required Graph permissions are granted.

  9. Reset the attachment control after upload.

  10. Use Power Automate for files larger than 4 MB.