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 *.
- SharePoint error - An exception occurred when trying to issue security token: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms..
- PowerShell iterate and get all SharePoint sites and sub sites
- SharePoint Online: Editing session has ended Message
- How to Share Microsoft SharePoint Site with Users or Groups
- How to delete SharePoint Online List Item using REST API
- SharePoint List excel import - This table exceeds the maximum number of supported rows
- How to disable SharePoint subsite creation option for owners
- SharePoint 2010 August 2015 Update KB3055049 - Duplicate Document ID issue bug fixed
- SharePoint Server 2016 Preview installation error - This Product Key isn't a valid Microsoft Office 2016 Product Key. Check that you've entered it correctly.
- How to upload file programmatically to SharePoint Document Library using Server Object Model C# .Net
- Access URL for SharePoint Tenant Admin Center (Online Office 365)
- Error when deleting SharePoint Online folder or file
- How to extend retiring SharePoint 2010 Workflows and continue with Office 365
- How to generate client id and secret to register SharePoint App with OAuth
- How to delete SharePoint List Item programmatically using C#.Net
- How to retrieve all SharePoint Online List Items using Rest API
- [Solved] SharePoint Search Internal server error exception
- Create SharePoint Site Collection using PowerShell New-SPSite
- Fix SharePoint PowerShell error - The term Get-SPweb is not recognized as the name of a cmdlet function script file or operable program
- How to enable anonymous public access for SharePoint Online site collection, file, folder without login ?
- SharePoint Server 2016 installation System Hardware requirements
- How to create SharePoint Online List Item using REST API
- Changed AD user display name showing old name in SharePoint
- Recommended size and resolution for SharePoint Online Site logo
- Microsoft 365: How to Turn Off Delve in SharePoint Online for All Users
- Fix: bash: syntax error near unexpected token - Bash
- Java Stream Convert List of Objects to List of Strings - Java
- Install Apache Tomcat ver 8 on Mac OS X Yosemite 10.10 - Mac-OS-X
- How to access SharePoint Online data using Postman - REST API and Bearer token - SharePoint
- Check Reboot History Mac - MacOS
- How to get Client IP address using Java Code Example - Java
- How to Escape a character in a Bash command String - Bash
- [fix] Docker - no matching manifest for linux/arm64/v8 in the manifest list entries [M/M2 Mac] - Docker