To delete an item from a SharePoint list, you can use the REST API or the SharePoint client object model. Here are examples of both methods:
Using REST API
You can send a POST request to delete the item:
POST https://{site_url}/_api/web/lists/GetByTitle('YourListName')/items({item_id})
Authorization: "Bearer " + accessToken
Accept: "application/json;odata=verbose"
Content-Type: "application/json"
If-Match: "{etag or *}"
X-HTTP-Method: "DELETE"
Replace YourListName with the name of your list and {item_id} with the ID of the item you want to delete.
Using Client Object Model (JavaScript)
You can also delete an item using the SharePoint JavaScript library:
var clientContext = new SP.ClientContext.get_current();
var list = clientContext.get_web().get_lists().getByTitle('YourListName');
var listItem = list.getItemById(itemId);
listItem.deleteObject();
clientContext.executeQueryAsync(
function() { console.log('Item deleted successfully'); },
function(sender, args) { console.log('Error: ' + args.get_message()); }
);
Make sure to replace YourListName and itemId with the appropriate values.
These methods will allow you to remove an item from your SharePoint list effectively.