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 *.
- Move Copy Migrate SharePoint OneDrive files folders to different site collection location
- How to generate client id and secret to register SharePoint App with OAuth
- How to share SharePoint site or document with all users in organization
- Get-ADUser PowerShell - Get AD user details using email address
- error CAML Query containing special characters
- Access URL for SharePoint Tenant Admin Center (Online Office 365)
- Fix SharePoint Error - The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started
- SharePoint - The URL is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web.
- How to delete SharePoint List Item programmatically using C#.Net
- How to Share Microsoft SharePoint Site with Users or Groups
- JSON column formatting to preview SharePoint Online file on mouse hover
- SharePoint List redirect user after submitting form NewForm.aspx
- See actual SharePoint error exception modify web.config
- SharePoint Server 2016 IT Preview Deprecated Removed features
- How to create SharePoint Document Library
- How to Get or Set SharePoint Document ID _dlc_DocId using PowerShell
- How to disable SharePoint subsite creation option for owners
- PowerShell - How to use Try Catch Finally blocks for error exception handling (Windows/SharePoint)
- SharePoint error - Your organization doesn't allow sharing with users from this domain. Please contact your IT department for help. (OSE403)
- [Solved] SharePoint Search Internal server error exception
- How to wrap column text in SharePoint Online Modern List Grid View using JSON formatting
- How to extend retiring SharePoint 2010 Workflows and continue with Office 365
- Changed AD user display name showing old name in SharePoint
- How to hide or remove quick launch left navigation from SharePoint Online Modern site page
- How to enable anonymous public access for SharePoint Online site collection, file, folder without login ?
- Calculate days between dates using dateutils ddiff command - Linux
- Fix Power BI error Access to the resource is forbidden when connecting SharePoint Online List as data source - SharePoint
- Increase Android Emulator Timeout time - Android
- Remove Possible Data Loss Message from Microsoft Excel - Microsoft
- How to turn on Bluetooth on Windows 10 - Microsoft
- Check SSH/OpenSSH version Command - Linux
- How to install AWS Toolkit for Visual Studio Code - AWS
- [Fix] java: integer number too large compilation error - Java