I have created an apex rest httppost class. This requires two parameters which are passed via response. I am trying to test this via workbench by passing two parameters.
@RestResource(urlMapping='/OpportunityDetails/*')
global class OppDetails
{
@HttpPost
global static void getDetails()
{
try
{
RestRequest request = RestContext.request;
RestResponse response = RestContext.response;
Opportunity opp = (Opportunity)JSON.deserialize(request.requestBody.toString(),Opportunity.class);
System.debug('----myopp: '+ opp);
}
catch(Exception ex)
{
}
}
The JSON deserialized value is empty even though I am passing two values.
I am not sure how to test this using postman but this is how I am testing via workbench. My idea is to get both the parameter values and then insert based on ID.
Debug logs show Response body as null.
RestResponse:[headers={}, responseBody=null, statusCode=null]