I'm following a design pattern set by one of our devs.
RestResource.RequestBody requestBody = RestResource.getRequestBody();
I'm trying to find documentation on this object, but I can't seem to find it anywhere. Is this design pattern outdated?
Should we be using something like RestContext instead?
Apex class
@RestResource(urlMapping='/endpoint')
global without sharing class myRestClass {
@HttpPost
global static void create() {
RestResource.RequestBody requestBody = RestResource.getRequestBody();
//Call your caller class
System.debug(requestBody.body);
myProcessingClass mp = new myProcessingClass(requestBody.body);
//Check response
System.debug('trying to process');
mp.processActivity();
RestResource.getResponse('SUCCESS', 201);
}
}
RestContext.response
instead ofRestResource.getRequestBody()
. Are you sure?