1

I have a power automate flow which creates a SharePoint subsite. Now once a subsite is created, I want to delete the "News" webpart that is on the SharePoint subsite.

I know to delete a web part we can use send http request to SharePoint site, I was able to delete a webpart using below URI. But this is specific to that particular webpart.

How can I dynamically use below expression so that every time a subsite gets created, it will delete a "News" webpart from the subsite.

Below is the URI I used to delete webpart.

_api/web/getfilebyserverrelativeurl('@{body('Parse_JSON')?['d']?['ServerRelativeUrl']}/SitePages/home.aspx')/webparts(guid'uaf1bc94-d17d-45d0-92ec-bb8e7a772j91')

I have hardcoded value of webpart GUID uaf1bc94-d17d-45d0-92ec-bb8e7a772j91.

Is it possible to use this value dynamically?

1 Answer 1

0

In the same Power Automate flow, you can first get all the web parts from the home page and then identify news web part using title or type to get its guid to pass it into your existing above REST API.

Steps to get web parts from Home page:

  1. Send an HTTP request to SharePoint: Use the REST API to get the web parts on the home page.
  2. API Endpoint: Use the following endpoint to get the web parts: _api/web/getfilebyserverrelativeurl('@{body('Parse_JSON')?['d']?['ServerRelativeUrl']}/SitePages/home.aspx')/webparts
  3. Parse the JSON and loop through the web parts and check for the type or title to identify the "News" web part.
1
  • I'm glad it worked for you. Commented Nov 4, 2024 at 13:50

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.