Skip to content

Instantly share code, notes, and snippets.

@TheShubhamVsnv
Created March 7, 2024 07:53
Show Gist options
  • Save TheShubhamVsnv/02668dd1a889e7824800f6bf515450fa to your computer and use it in GitHub Desktop.
Save TheShubhamVsnv/02668dd1a889e7824800f6bf515450fa to your computer and use it in GitHub Desktop.
//DELETE: Remove data or resources from Salesforce.
@future (callout=true)
public static void deleteContacts () {
// Creating a new HTTP request
HttpRequest req = new HttpRequest();
// Setting the endpoint for the HTTP request
// SourceOrgNamedCredential is your SourceORG Named Credential
// 003F900001gMifVIAS is the Id of targetORG contact which we are updating
req.setEndpoint('callout:SourceOrgNamedCredential/services/apexrest/Contact/003F900001gMifVIAS');
// Setting headers for the HTTP request
req.setHeader('content-type','application/json; charset=UTF-8');
req.setHeader('Accept','application/json');
// Setting the HTTP method to DELETE
req.setMethod('DELETE');
// Creating a new HTTP object
Http http = new Http();
// Sending the HTTP request
HttpResponse response = http.send(req);
// Debugging the response
System.debug('response code : ' + response.getStatusCode());
System.debug('response Body: ' + response.getBody());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment