0

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);


    }
}

Screen Shot of Documentation on System Namespace

12
  • Thanks, I've read this page but was curious about the RestResource.RequestBody method. It doesn't seem to be anywhere.
    – thinker
    Commented Jul 9, 2020 at 13:59
  • 2
    For me I feel that you wanted RestContext.response instead of RestResource.getRequestBody(). Are you sure? Commented Jul 9, 2020 at 14:05
  • 1
    What is the API version of the implementation you have @thinker? Maybe that is what we need to look at. Could you post some portion of the code you have? Commented Jul 9, 2020 at 14:53
  • 2
    Sounds like the developer created RestResource as a (custom) Apex class.
    – identigral
    Commented Jul 9, 2020 at 17:09

0

You must log in to answer this question.

Browse other questions tagged .