You can delete a SharePoint List item using REST API with Spfx in modern or Content/Script Editor in classic development with HTML and jQuery.
This post assumes you have a SharePoint list named "List1" and want to delete List Item with ID 11 (use ID to refer to the item as ID filed is always unique).
If you are connecting to the List from outside of SharePoint like Java, .Net or Python code, you need to use a Bearer token (Client ID and Client Secret) to access the REST url.
Steps to generate Client ID and Secret - Register SharePoint App
✔️ Delete SharePoint List Item using HTML, jQuery, Ajax
We will use DELETE method to delte the SharePoint record. Assumptions,List Name = List1
List Item ID = 11
var webURL = _spPageContextInfo.webAbsoluteUrl;
$.ajax({
url: webURL + "/_api/web/lists/GetByTitle('List1')/items(11)",
type: "POST",
async: false,
headers: {
"Accept": "application/json;odata=verbose",
"X-Http-Method": "DELETE",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"If-Match": "*"
},
success: function(data) {
//Perform further activity upon success, like displaying a notification
},
error: function(data) {
//Log error and perform further activity upon error/exception
}
});
✔️ Delete SharePoint List Item using Postman
For testing SharePoint REST API with Postman, you need to use the Client ID, Client Secret, Tenant ID, to generate a Bearer token.Steps to generate SharePoint Bearer token - How to test SharePoint REST API from Postman
Once you have generated the access token, follow below steps
- Initiate a DELETE method request.
- Apply Header configuration parameters as below.
- Enter request url in below format
- Click Send.
- You should get a 200 OK response.
- Validate the changes form SharePoint.
Key | Value |
Accept | application/json;odata=verbose |
Content-Type | application/json |
Authorization | Bearer <<oken> |
If-Match | * |
https://c2c.sharepoint.com/sites/SPDev/_api/web/lists/GetByTitle('List1')/items(11)
If you get a 412 Precondition Failed error with message "The request ETag value does not match the object's ETag value", add Header parameter key "If-Match" and set its value as *.
- Managed Metadata error - The data returned from the tagging UI was not formatted correctly
- How to generate client id and secret to register SharePoint App with OAuth
- Create SharePoint Site Collection with new Content database in existing web application
- Fix Error 2711 SQL RBS client - The installer has encountered an unexpected error. The specified Feature name ('Docs') not found in Feature table
- How to exclude results from SharePoint Search
- 'Edit Document' Requires a Windows Sharepoint Services-compatible application and Microsoft Internet Explorer 6.0 or higher
- [Solved] SharePoint Access Denied error editing Document Name
- Recommended size and resolution for SharePoint Online Site logo
- SharePoint Server 2016 IT Preview - new improved Features and Enhancements
- Restore deleted Office 365 SharePoint group site
- SharePoint An unexpected error has occurred - Correlation ID and PowerShell Merge-SPlogfile
- [Solved] SharePoint Search Internal server error exception
- SharePoint CAML query error - The XML source is not correct
- How to hide quick launch in SharePoint classic site
- Not receiving email notification alert in SharePoint Online workflow - Power Automate, FLOW
- Change SharePoint search results FullTextSqlQuery RowLimit 10000
- Fix Power BI error Access to the resource is forbidden when connecting SharePoint Online List as data source
- [Fix] Restricted View permission level missing in SharePoint Online site library
- How to upload file programmatically to SharePoint Document Library using Server Object Model C# .Net
- How to create classic site in SharePoint Online
- That did'nt work, Issue type User not in directory - SharePoint external access error
- Merge-SPlogfile PowerShell - SharePoint Correlation ID error
- Fix Power BI 404 not found error when connecting SharePoint Online List as Data Source
- SharePoint Server 2016 IT Preview Deprecated Removed features
- SharePoint error - An exception occurred when trying to issue security token: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms..
- Android Studio : Change FAB icon color : FloatingActionButton - Android-Studio
- Set Python 3.8 as a default python version on macOS - MacOS
- Microsoft Lists and SharePoint Online edit grid view - use undo and redo changes - SharePoint
- Make Android View Scrollable both Horizontally and Vertically - Android
- How to Enable Dark Mode Theme in Microsoft Teams - Teams
- MySQL ERROR 1064 (42000): You have an error in your SQL syntax [fix] - MySQL
- Adding internet permission to Android Project - Android
- How to Undo-Revert Sent Email in Google Gmail - Google