How to see JSON response for REST service?

You can head over Salesforce Workbench and use the REST Utility to test the endpoint .

enter image description here

Your endpoint to test will be

/services/apexrest/BP_Routes

Also looks like the method is accepting a string parameter ,so you will need to select post and then the JSON input is

{
  "username" : "test"
}

The response will tell you the JSON structure .Also just by looking into the ResponseWrapper class you will know the structure of the JSON .


IN exec anonymous simply type:

system.debug(BP_Routes.BP_Routes('APPROPRIATEUSERNAMEHERE'));

and it will debug what is returned. If you like you can serialize it since it is not serialized in your class:

system.debug(JSON.serializePretty(BP_Routes.BP_Routes('APPROPRIATEUSERNAMEHERE')));

And the other answers work as well, this is just pretty easy to do without leaving org


It will be based on the return type you are sending. For example your code is sending ResponseWrapper for HTTP-Post call with URL '/services/apexrest/BP_Routes'

Let's assume you have defined RepsonseWrapper structure as below -

global Class ResponseWrapper{
    public String statusCode;
    public Datetime responseOut;
    public Integer recordCount;
    public List<Map<String, String>> errorMessages;


    public ResponseWrapper(){}
}

The JSON response would be like as below -

{
    "statusCode":"ERROR",
    "responseOut":"2017-04-14T01:01:01.000Z",
    "recordCount":0,
    "errorMessages":[{"errorMessage":"Some Error Message","errorCode":"SOME_ERROR_CODE"}],
}