• subramani Ramamurthy
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Using a RestResource with a @HttpPost method with parameters, the RestContext.request.requestBody is null compared to a methods without parameters. Is this a bug?

1) Without parameters, RestContext.request.requestBody is not null
@RestResource(urlMapping='/TestRestA/*')
global class WS_TestRestA {
    global class TestIt {
        global String Error;
        global Boolean IsSuccess;
    }

    @HttpPost
    global static void createTestIt() {
        String jsonStr = null;
        if (null != RestContext.request.requestBody) {
            jsonStr = RestContext.request.requestBody.toString();
        }
        System.debug(LoggingLevel.ERROR, 'jsonStr ===> ' + jsonStr);
    }
}

Using Workbench: REST Explorer with JSON {"testItRec" : {"Error" : "An error", "IsSuccess" : false}}
Output:
...
USER_DEBUG|[24]|ERROR|jsonStr ===> {
  "testItRec" : {
     "Error" : "An error",
     "IsSuccess" : false
  }
}
...  

2) With parameter, RestContext.request.requestBody is null
@RestResource(urlMapping='/TestRestA/*')
global class WS_TestRestA {
    global class TestIt {
        global String Error;
        global Boolean IsSuccess;
    }

    @HttpPost
    global static void createTestIt(TestIt testItRec) {
        String jsonStr = null;
        if (null != RestContext.request.requestBody) {
            jsonStr = RestContext.request.requestBody.toString();
        }
        System.debug(LoggingLevel.ERROR, 'jsonStr ===> ' + jsonStr);
    }​
}

Using Workbench Rest Explorer with JSON {"testItRec" : {"Error" : "An error", "IsSuccess" : false}}
Output:
...
USER_DEBUG|[34]|ERROR|jsonStr ===> null
... 
  • January 26, 2015
  • Like
  • 0

anyone know how to find out what edition of salesforce an org has i.e. unlimited, enterprise, professional etc..