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 Automate / BadGateway status code...
Power Automate
Suggested Answer

BadGateway status code 502 running Excel Online Office script with 7800 csv records.

(1) ShareShare
ReportReport
Posted on by 13
I am running a power automate cloud flow. The action (Run Office Script) from Excel online is failing (bad gateway) when trying to run an office script that uses to convert CSV data into an excel table. 
When execution with just a few records from the csv file (100 records) to action finishes fine. But I am now trying the full load of csv records that need to be converted, which is about 7,820 records. 
I downloaded the Action input to verify, and it seems it has all the data needed, which in JSON format is about 11,077kb in size. 
The action output error is the following: 
 "body": {
        "error": {
            "code": 502,
            "source": "flow-apim-unitedstates-002-eastus-01.azure-apim.net",
            "clientRequestId": "419dfdbf-09df-401b-9030-7e7b05cc26ce",
            "message": "BadGateway",
            "innerError": {
                "StatusCode": 500,
                "Message": "Oops! Something went wrong.\r\nclientRequestId: 419dfdbf-09df-401b-9030-7e7b05cc26ce",
                "RequestId": "419dfdbf-09df-401b-9030-7e7b05cc26ce"
            }
        }
    }
Is this error because of the large size of data that needs to be processed? Can I adjust any configuration to increase processing capacity?
Categories:
I have the same question (0)
  • Suggested answer
    11manish Profile Picture
    943 on at
    In Microsoft Power Automate, your Run Office Script (Excel Online) action works for small data (~100 rows) but fails with:
     
    • ❌ 502 BadGateway / 500 internal error
    when processing ~7,820 rows (~11 MB JSON payload).
     
    Root Cause
    Yes — this is very likely due to size & execution limits
     
    Key constraints in Microsoft Excel Online + Office Scripts:
    • Payload size limits (request/response)
    • Script execution time limits (~2–5 minutes)
    • Memory constraints inside Office Scripts
    • Connector throttling / API gateway limits
    Your 11 MB JSON + transformation logic is exceeding one or more of these limits.
     
    Important
    • You CANNOT increase capacity/config limits for:
      • Office Script runtime
      • Excel Online connector
      • Power Automate action timeout (for this connector)
    Recommended Solutions (Best Practices)
    Split Data into Chunks (Most Recommended)
    Instead of sending 7,800 rows at once:
    • Break into smaller batches (e.g., 500–1000 rows)
    Flow pattern:

    CSV → Parse → Split array → Apply to each (batch)
           ↓
    Run Office Script per batch
     
    • Avoids timeout
    • Prevents payload overflow
    Avoid Passing Large JSON to Script
    Instead of:
    • Flow → pass full JSON → script processes
    Do this:
    • Store CSV in OneDrive/SharePoint
    • Let script read file directly
    ✔ Reduces payload size
    ✔ Improves performance
     
    Thanks
    Manish
     
     
  • Suggested answer
    Valantis Profile Picture
    2,651 on at
     

    it’s platform limits. there’s nothing you can “turn up.”

    try this:

    • Resave the workbook as standard .xlsx (not “Strict Open XML”). This specific format causes BadGateway with Run script.
    • Batch your writes in the Office Script (e.g., ~1,000 cells per batch) instead of one large setValues. Use the “Write a large dataset” pattern.
    • If it still runs >120 seconds, split the flow to call Run script in a loop over CSV chunks (each under the 5 MB per-call workbook interaction and <120 s). Your ~11 MB input is below the 30 MB Run script parameter cap; the bottlenecks are the 5 MB Excel call limit and the 120 s timeout.

    Validate

    • Rerun the flow; confirm no 502 and that all 7,820 rows are written in batches within ~120 s per run.

    Sources

     

     

    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/

     

  • Valantis Profile Picture
    2,651 on at

    Hi @FG-27031939-0,

    Just wanted to check in and see if everything is working now. If you still need any help, feel free to let me know.

    Also, if the issue is resolved, it would be great if you could mark the answer as solved so others with the same question can find it easily.

     

    Thanks and have a great day!

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 612

#2
Valantis Profile Picture

Valantis 344

#3
11manish Profile Picture

11manish 326

Last 30 days Overall leaderboard