web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / how to remove webpart/...
Power Automate
Unanswered

how to remove webpart/s from sharepoint site using power automate

(2) ShareShare
ReportReport
Posted on by 172

I have tried multiple ways to remove particular webparts in a site collection thats on the home.aspx page but keep getting resource not found.

I have passed the following uri

https://xxx.sharepoint.com/sites/24458/_api/web/getfilebyserverrelativeurl('/sites/24458/SitePages/Home.aspx')/getLimitedWebPartManager(scope=1)/webparts('webpartIdGuid')

Also tried

_api/web/getfilebyserverrelativeurl('/sites/24458/SitePages/Home.aspx')/getLimitedWebPartManager/webparts/getbyid('webpartIdGuid')
 
I used webpart GUID from the data-sp-web-part-id on the page (via view source)
 

Using the Send an HTTP request to SharePoint 

Site Address : Site Collection Url 

Method:Post 

Headers

{
  "Accept": "application/json;odata=verbose",
  "X-HTTP-Method": "DELETE",
  "IF-MATCH": "*"
}

I'm not sure what am missing. Any help would be appreciated

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at
     
    You can use the Graph API/SharePoint Pages API for this. A delete webpart method exists in that API:
     
    Below is an example setup (test it properly first before you move it into production).
     
    _api/v2.0/sites('@{variables('SiteId')}')/pages/@{variables('SitePageId')}/oneDrive.page/webParts/@{variables('WebPartId')}
     


     
     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel
  • naijacoder Profile Picture
    172 on at
    Thanks for you response
    using the uri below
    _api/v2.0/sites('46f7d5ae-0c5e-4711-9910-8898e141c29b')/pages/'11'/oneDrive.page/webParts/c4bd7b2f-7b6e-4599-8485-16504575f590
     
    I get error
    Unexpected response from the service
    clientRequestId: 024e186b-2f5a-404a-8a67-5f00fcd39ae0
    serviceRequestId: 339583a1-3083-4000-c335-9128b0fc42c4

    Is there anything i'm doing wrong perhaps?
     
     
    Is the data-sp-web-part-id the correct id for the webpart and is the pageid a guid or a whole number?
     
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at
     
    Those would be the Graph API object ids, those are different. Apologies for being unclear about that. Do you know how to collect those?
     
    Below are the ids from my example to give you an idea of the format of those values, if that helps?
     
     

    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel
  • naijacoder Profile Picture
    172 on at
    Oops i got I forgot to select DELETE instead of GET :)
     
    Hi there,
    I decided to give a try using MS Graph explorer and this is the test webpart i want to remove
    See below and i have given the right consent but it isn't doing any thing.
    What should i be adding in my header. I feel i'm missing something .
    Thanks
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at
     
    I see in your screenshot you used GET method in the Graph Explorer. Try and Select the DELETE method (see the screenshot below).
     
    Just a heads-up, the format of the Url would be different in the Graph Explorer compare to the Send an HTTP request to SharePoint action. I adjusted my example to be used in that specific action.
     
    For the Graph Explorer application you can just follow the docs examples.
     
     
     
     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel
     
  • naijacoder Profile Picture
    172 on at
    Thanks for you response Expiscornovus
    I finally got it working using Send an HTTP request to SharePoint.
    My question to you is what api can i use to ad a new webpart with data?
    Can the Send an HTTP request to SharePoint do this or i have to use graph?

    Thanks in advance
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at
    Hi,
     
    You can add a web part with SharePoint REST API or the Graph API. Both can be used in a Send an HTTP request to SharePoint action.
     
    However, the Graph API doesn't support all type of web parts yet. What kind of new web part do you want to add?
     
     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel
  • naijacoder Profile Picture
    172 on at
    Thanks Expiscornovus
    I would like to a quicklink , image galleryor Stream webparts
    Is this possible with the  Send an HTTP request to SharePoint action?
    If you have any resources or links pls share

    Thanks
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at
    Quick Links and Image Gallery are supported by the Graph API. Video I would need to double check, you might be able to use the Document Embed for that as well
     
    Additionally, I have written a blog about the Quick Links a couple of days ago:
     
    I will probably also create blogs for the Image Gallery and the Document Embed in the next few days as well 😁

     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel
     
     
  • naijacoder Profile Picture
    172 on at
    Thanks so much Dennis for your time.
    I actually came across your blog below earlier. This was very useful s its really hard to find good docs from MS
     
    and i have been able to put thngs together for the Image Galley and Image webpart.
     
    Also one more question and please let me know if this is even possible.
    I have some links in the quicklaunch in a sharepoint site that i would like to remove.
    I can easily receive the navigation quicklaunch including the node id but can get to remove them using the below api via power automate

    To get all quicklaunch
    /_api/Web/Navigation/QuickLaunch?$select=Id,Title

    To remove I tried the 2 below (Not sure if its the right rest api)
    /_api/Web/Navigation/QuickLaunch/removelink/2030 or /_api/web/Navigation/DeleteNodeId(2030)

    There is nothing here
    https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-csom/jj171813(v=office.15)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard