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 App SharePoint S...
Power Apps
Answered

Power App SharePoint Site Pages Power Automate API running with only intermittent success

(0) ShareShare
ReportReport
Posted on by 82
Hoping someone can advise, as this is driving me potty...
 
I am running a Power Automate flow from a Power App, to
  • query a SharePoint Site's "Site Pages" List using a "Send an HTTP Request to SharePoint" action; and
  • return the response to the App using the "Respond to a Power App of flow" for processing.
All standard stuff.
 
Understood, that this should probably be done using a graph request, but I'd very much like to stick with SharePoint API for now. ;-)

When a button is clicked in the App, the flow triggers correctly, runs correctly, and populates the "Respond to a Power App or flow" correctly.
 
If I click the button ten times, it will work maybe three times. The remainder of times, the App will hang for two to three minutes (the flow itself takes c. 406ms to 895ms), then return an empty collection. I have tried removing then re-adding the flow from the App, and also removing then re-adding the "Respond to a Power App" control. Given that the whole process does work, if only intermittently, and that the flow works 100% of the time, I am thinking that the issue is in the App, or in my script, rather than in the flow.
 
I have no issue querying SharePoint Sites with one or two Site Pages. Understood, that I can only retrieve the top 100 pages of any given Site. However, with a Site I'm currently testing, containing 43 pages, the App will sometimes work, and sometimes not.
 
Here is the script I use:
 
//  Collects Site Pages in the specified Site using an API call
 
//  Onscreen banner, to advise that the App is doing something
 
    Set(varWorkingOnIt, "Retrieving Site Pages for the specified Site using API... this may take a mo or two depending on the number of pages...");
 
//  Resets any variables and collections
 
    Set(varSitePages, Blank());
    Clear(colSitePages);
 
//  Sets the response of the flow in a variable
 
    If(
        IsBlankOrError(
        Set(varSitePages,
            SPAPIEndpointExplorer.Run(
            "https://TENANT.sharepoint.com/teams/" & varLookUpSite,                               //  Team Site Code
            "GET",                                                                                //  REST Method
            "_api/web/lists/GetByTitle('Site%20Pages')/items?$select=Title,ID,Created,Modified,CanvasContent1,FileLeafRef&$expand=Author&$select=Author/Id&$expand=Editor&$select=Editor/Id",                                                                                                        //  URI
            "{                                                                                  
                'accept': 'application/json;odata=nometadata',
                'content-type': 'application/json'
               
            }",                                                                                   //  http headers
            ""                                                                                    //  body if needed
            ).response
        )
    ),
 
//  If error, notifies the User
 
    Notify("Unable to collect Site Pages for the specified Site. Please try again. If symptoms persist, shoot the Developer.", NotificationType.Warning),
 
//  If no error, collects the variable values in a table
 
    Collect(
        colSitePages,
        ForAll(
            Table(ParseJSON(varSitePages).value),
                {
                    Content: Text(Value.CanvasContent1),
                    Created: Text(DateTimeValue(Text(Value.Created)), "[$-en-US]dd-mmm-yyyy, hh:mm am/pm"),
                    'Created By': Text(Value.Author.Id),
                    ID: Value(Value.ID),
                    Modified: Text(DateTimeValue(Text(Value.Modified)), "[$-en-US]dd-mmm-yyyy, hh:mm am/pm"),
                    'Modified By': Text(Value.Editor.Id),
                    Link: Text(Value.FileLeafRef),
                    Title: Text(Value.Title)
                }
            )
        );
 
//  Clears the banner
 
    Set(varWorkingOnIt, "");
 
//  Navigates to the screen for a gallery review of the collection
 
    Navigate('Review API Screen *')
 
    )
 
I think this is fairly solid.
 
Any suggestions will most gratefully received...?!   
Categories:
I have the same question (0)
  • Verified answer
    11manish Profile Picture
    3,333 on at
    Most Likely Root Cause — Response Size / Serialization Delay, especially when the flow returns large JSON payloads (which your SharePoint Site Pages query does because of CanvasContent1).
     
    Your API request returns:
    • CanvasContent1
    This column contains full page JSON + HTML, which can be very large.

    Recommended Fix 
    • Only return lightweight metadata first.
    • Avoid ParseJSON When Possible
    • ParseJSON() is expensive.  Instead return structured output from the flow.
  • gregmck Profile Picture
    82 on at
    Thank you, , really appreciate the response, and the suggestion for the cause of the error, which does make perfect sense. :-)
     
    The accumulated CanvasContent1 does return a very large amount of data, which I was hoping to parse - in one go - within the App (the flow I use is a generic one, which I use for a number of different types of API call, so doesn't permit selection and return of specific elements for specific calls to the App from within the flow).
     
    I did find a workaround, which was to get a list of the IDs for every page in the Site, then to run a targeted, cumulative, request and Collect operation for each item()'s data, which is working, although it is not ideal! Again, I should probably start using Graph, and Graph's (easier?!) identification of webparts. It's the age-old problem of brain power vs. scripting options. Just wish I (or at least my brain!) was a good twenty years younger... ;-)

    Thanks again for the response, and for providing the answer to the question.

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