Skip to content

Instantly share code, notes, and snippets.

@TheShubhamVsnv
Created March 7, 2024 07:52
Show Gist options
  • Save TheShubhamVsnv/3cf849544d48c975c82163454a3b39c5 to your computer and use it in GitHub Desktop.
Save TheShubhamVsnv/3cf849544d48c975c82163454a3b39c5 to your computer and use it in GitHub Desktop.
@HttpDelete
global static string deleteContact() {
// Retrieving the incoming REST request
RestRequest req = RestContext.request;
// Extracting the contact Id from the request URI
String contactId = req.requestURI.substring(req.requestURI.lastindexof('/') + 1);
// Querying for the contact record to be deleted
Contact contact = [SELECT Id FROM Contact WHERE id = :contactId LIMIT 1];
// Deleting the contact record
delete contact;
// Returning a success message
return 'Success Deletion';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment