i came across this code
@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource {
@HttpDelete
global static void doDelete() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account account = [SELECT Id FROM Account WHERE Id = :accountId];
delete account;
}
}
but im not able to understand what does
DoCan anybody tell what exactly RestResponse do with an exampleThanks,​​​​​​​​​​​​​​RestResponse res = RestContext.response;
1 answer
It looks like In this method they are not using RestResponse.Initialized but it is not used anywhere.RestResponse res = RestContext.response is not doing anything here.Usually RestResponse object is used to pass data from an Apex RESTful Web service method to an HTTP response.Please refer below link which might help you in thishttps://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_restresponse.htmHope this helps youLet me know if this helps you. Kindly mark it as solved so that it may help others in future.Thanks and Regards