Abhishek Singh
Abhishek Singh

Reputation: 101

Delete office 365 sharepoint site using rest api

I am trying to delete Office 365 SharePoint site using rest API but i don't know how to do it. Is there any way to delete office 365 SharePoint site using rest APi.

Note: I am using Graph Explorer to create site on SharePoint and now i want to completely delete it.

Upvotes: 0

Views: 1599

Answers (1)

Michael Han
Michael Han

Reputation: 3655

Try this:

var restAPIURL = "siteurl/_api/web"  
$.ajax  
({    
    url: restAPIURL,    
    type: "POST",  
    async: false,  
    headers: {  
         "accept": "application/json;odata=verbose",  
        "content-type": "application/json;odata=verbose",  
        "X-RequestDigest": $('#__REQUESTDIGEST').val(),    
        "X-HTTP-Method": "DELETE"  
    },   
    success: function(data){    
         console.log('site deleted');  
    },    
    error: function(data){   
        console.log('Error deleting site');   
    }    
}); 

Reference:

https://social.technet.microsoft.com/wiki/contents/articles/37462.sharepoint-online-office-365-delete-sharepoint-site-using-rest-api.aspx

https://www.c-sharpcorner.com/article/create-retrieve-update-or-delete-sites-on-sharepoint-using-rest-api/

Upvotes: 0

Related Questions