
The code in source is: Http h = new Http(); HttpRequest req = new HttpRequest(); req.setMethod('DELETE'); req.setHeader('Authorization','Bearer '+Helper.GetAccessToken().access_token); req.setHeader('Content-Type','application/json; charset=UTF-8'); //call the rest resource URL and this url needs to be registered in remote settings req.setEndpoint('https://ap2.salesforce.com/services/apexrest/AccountRest'); HttpResponse res = h.send(req); // JSON string is generated at this point system.debug('---res.getBody()--'+res.getBody());In res.getBody() , I am getting the ID of the record which was passed from sourceNow how do I pass this ID back to source indicating that this record is to be deleted.I hope I am clearThankspooja@HTTPDelete
webservice static string DeleteAccounts()
{
Account a=[select Id from account where Name LIKE :'%TVS Electronics%'];
return a.ID;
}
}
2 Antworten

Hey Pooja,Can you confirm why you are returning this Id back from the Rest Resource?You are using the @HttpDelete (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_http_delete.htm) annotation which is called when a HTTP Delete request is sent. I am also certain you should be performing a DELETE DML (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_section.htm) operation rather than returning the ID. I may have misunderstood your objective.Thanks,Thomas Smith.