I have created a rest resource in apex and I am passing in an id through the body through post man via GET request. I then deserialize the body and I am getting an empty string even when I am providing the id. code below.
// rest resource code, More to code but I think this is the important stuff
String res = RestContext.Request.requestBody.toString();
if(res == ''){
response.statusCode = 400;
return;
}
HogtieDTO.getDeviceRequestInfoResponse resData = (
HogtieDTO.getDeviceRequestInfoResponse)JSON.deserialize(
RestContext.Request.requestBody.toString(),
HogtieDTO.getDeviceRequestInfoResponse.class
);
//HogtieDTO class
public with sharing class HogtieDTO {
public class getDeviceRequestInfoResponse {
public String customerId;
}
}
I get the 401 after i make this call.
I can get it to work by passing it via a param but Im trying to get it to work through the body.