I have seen some examples over the internet to parse the JSON, but still I'm unable to parse and store the values into a object for the Patch operation.
/services/apexrest/id/00hjkl00000kl00
below is the sample JSON
{
"Details":{
"SSN" : "1234",
"FULLSSN" : "12345678"
}
}
This is the Apex class that I wrote
@RestResource(urlMapping='/id/*')
Global class Restservice{
@Httppatch
global static String doput() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
Id leadid = req.requestURI.substring(req.requestURI.LastIndexOf('/')+1);
Lead lead1 = [SELECT ID, isConverted FROM Lead WHERE id =: leadid];
if(lead1.isconverted)
{
Blob jsonBlob = req.requestBody;
String jsonString = jsonBlob.toString();
//I need to update the SSN and FULLSSN (From JSON) values in to this existing lead
return 'Success';
}
else
return 'Failure';
}
public class Details {
public String SSN;
public String FULLSSN;
}
}
Any help is much appreciated. Thanks!