You need to sign in to do that
Don't have an account?
Agnibha Chakrabarti 10
What does RestResponse class do in Apex REST webservice
hi, I'm learning apex Rest web service.
i came across this code
but im not able to understand what does
Do
Can anybody tell what exactly RestResponse do with an example
Thanks,
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
RestResponse res = RestContext.response;
Do
Can anybody tell what exactly RestResponse do with an example
Thanks,
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 this
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_restresponse.htm
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards