Delete sharepoint site via graph API

Pankaj Mandrawal 0 Reputation points
2023-03-27T05:34:02.26+00:00

Hello, I am not delete sharepoint site using graph api, but it's not giving me 200 as a status code.

it's giving 404- file not found, when I hit the delete API endpoint.

_api/SPSiteManager/delete

I am using the above endpoint.

Please, help me in this how do I validate. whether site has deleted or not

thanks!

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
3,873 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,714 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,737 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 31,681 Reputation points Microsoft Vendor
    2023-03-27T06:19:12.7433333+00:00

    Hi @Pankaj Mandrawal

    You should check if the site is a group connected site. When it is a group connected site you could use the Delete Group method from the Graph API in a Send an HTTP request action of the Office 365 Groups connector.

    DELETE https://graph.microsoft.com/v1.0/groups/{id}
    
    

    If it is a modern site (Communication sites and Non-group associated Team Sites) you should be able to use the _api/SPSiteManager endpoint in a Send an HTTP request to SharePoint action.

    Delete a modern site

    url: /_api/SPSiteManager/delete
    method: POST
    accept: application/json;odata.metadata=none
    odata-version: 4.0
    body:
    {
      "siteId":"d11e59ca-1465-424c-be90-c847ba849af5"
    }
    
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.