Microsoft Flow SharePoint转Teams报HTTP 413错误求助
Alright, let's tackle this HTTP 413 "Payload Too Large" error you're hitting when sending Base64-encoded attachments to Teams via Microsoft Flow. Since you confirmed the message structure works in the Actionable Message playground, the issue is definitely tied to the oversized payload from those Base64 attachments. Here's how to fix it:
First, confirm the root cause: Teams Webhook Payload Limits
Teams incoming webhooks have a strict payload size limit (typically around 2MB). Since Base64 encoding increases file size by ~33%, even a 1.5MB original file will push the payload over the limit. To verify this:- Test sending your message without attachments—if it succeeds, you’ve confirmed the attachments are the culprit.
- Try attaching a small file (under 1MB) encoded as Base64; if that works, size is definitely the issue.
Best Fix: Replace Base64 Attachments with Cloud Links
Instead of embedding Base64 content directly into the payload, upload the SharePoint attachment to a cloud storage location (like a dedicated SharePoint library or OneDrive) and include a download link in your Teams message. This keeps the payload tiny and avoids the 413 error entirely.
Here’s how to adjust your Flow:- Add an action to save the SharePoint attachment to a cloud storage location (e.g.,
Create filein OneDrive/SharePoint). - Generate a shareable link for the uploaded file (use
Create share linkaction). - Insert this link into your Teams message body instead of the Base64 attachment.
- Add an action to save the SharePoint attachment to a cloud storage location (e.g.,
If You Must Use Base64: Compress Attachments First
If your use case requires embedding attachments directly, add a compression step to reduce the file size before encoding:- Use the
Zip fileaction in Flow to compress the SharePoint attachment(s) into a single ZIP archive. - Encode the ZIP file as Base64 instead of the original attachments—this can drastically reduce payload size, especially for files like documents or images.
- Double-check that the compressed Base64 payload stays under Teams’ 2MB limit.
- Use the
Advanced: Switch to Microsoft Graph API for Higher Limits
Incoming webhooks are great for simple messages, but if you regularly need to send large attachments, consider using the Teams Graph API instead. The Graph API supports direct attachment uploads to channels and has higher size limits, avoiding the need for Base64 embedding entirely.Double-Check Your Base64 Encoding
Even though your message worked in the playground, ensure Flow isn’t adding extra characters (like line breaks) to the Base64 string during encoding. Use aComposeaction to output the raw Base64 content and verify it matches the clean encoding you tested in the playground.
内容的提问来源于stack exchange,提问作者chriscam85

