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 / Power-apps is giving e...
Power Apps
Suggested Answer

Power-apps is giving error code 502

(1) ShareShare
ReportReport
Posted on by 7,431 Super User 2026 Season 1
Hello Everyone,
 
We have used the Graph API Inside the Power-apps to extract the contents inside the document it was working with smaller chunks of dataset but when record increased more than 2000 its failed with the below error.
 
Power Fx
  • varPageNumber ----> 1
  • varPageSize ----> 25
Set(
    requestbody,
    "{
        ""requests"": [
            {
                ""entityTypes"": [
                    ""listItem""
                ],
                ""query"": {
                    ""queryString"": """ & Substitute(GlobalSearchKeyword, """", "\\""") & " Refineablestring04:No IsVersionDocWSCHCS:No (DocStatusOWSCHCS:Published OR DocStatusOWSCHCS:\\""Overdue for Update\\"" OR DocStatusOWSCHCS:\\""Under Review\\"" OR DocStatusOWSCHCS:Draft OR DocStatusOWSCHCS:\\""Under Review\\"") " & tempGBSearchFilter & " PATH:\\"" & SearchPath & "\\"""
                },
                ""sortProperties"": [
                    {
                        ""name"": ""title"",
                        ""isDescending"": false
                    }
                ],
                ""size"": " & varPageSize & ",
                ""from"": " & ((varPageNumber * varPageSize) - varPageSize) & ",
                ""fields"": [
                    ""id"",
                    ""name"",
                    ""title"",
                    ""webUrl"",
                    ""siteowstext"",
                    ""doctypeowstext"",
                    ""refinablestring01"",
                    ""docstatusowschcs"",
                    ""refinabledate00"",
                    ""docstatusowschcs"",
                    ""curdocversionowstext"",
                    ""listitemid""
                ]
            }
        ]
    }"
);
 
 
Error Screenshot
 
Categories:
I have the same question (0)
  • Suggested answer
    Haque Profile Picture
    3,653 on at

    Hi @MS.Ragavendar,

    The Power Fx code is using pagination (varPageNumber and varPageSize) to request chunks of data from the Graph API - a good approach for handling large datasets. However, when the record count exceeds around 2000, the request fails, likely due to API limits, timeout, or throttling.

    Checkpoint-1: Instead of calculating from and size manually, use the API's continuation tokens or next links to fetch subsequent pages. This ensures reliable paging without skipping or duplicating records - did you  try this?

    Checkpoint-2: If not heavily nedeeded  can you please lower varPageSize (e.g., 10 or 20) to reduce load per request and avoid timeouts - will help a bit.

    Checkpoint-3: Can we narrow down the query to reduce the result set size, e.g., by date ranges or specific metadata filters to refine queries at the very first place?

    Checkpoint-4: We can offload large data extraction to Power Automate flows that can handle pagination and retries better, then return smaller chunks or summaries to Power Apps -we can give a shot?

     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
     
     
     
  • Suggested answer
    11manish Profile Picture
    3,333 on at
    It seems that the issue is not with the basic Power Fx syntax.
     
    The failure is happening because the Microsoft Graph Search API query becomes too expensive when the document volume increases beyond ~2000 records.
     
    The combination of complex filters, sorting, pagination, and the Office365Groups.HttpRequest connector is causing the API to timeout and return 502
     
    BadGateway.
  • Power Platform 1919 Profile Picture
    2,254 Super User 2026 Season 1 on at
    You can try checking the network calls using your browser’s Inspect -> Developer Tools.
    Look under the Network tab for the request usually labeled something like “Invoke” Request.
    That call often contains far more detailed error information than the generic Internal Server Error message you see in the UI.

    If something is failing upstream, the payload or response headers there will usually point you in the right direction.
     
    Another option is to use Live Monitor, which surfaces the same underlying request/response details in real time. It’s a good way to confirm whether the issue is consistent or intermittent.

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 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard