You need to sign in to do that
Don't have an account?

Please help me parse this json. I am getting an error: unexpected parameter Os
{"example":{"Os":"windows","Origin":"xyz"}} is my request string that is sent to a HTTPPost REST Web service in salesforce.
@RestResource(urlMapping='/NewIncident/*')
global without sharing class WSIncident {
@HttpPost
global static String createMobileCase(string example) {
contact newCase = new contact();
JSONParser jParser = JSON.createParser(example);
/*CAN SOME ONE PLEASE HELP ME PARSE THIS JSON*/
return newCase.Id;
}
}
@RestResource(urlMapping='/NewIncident/*')
global without sharing class WSIncident {
@HttpPost
global static String createMobileCase(string example) {
contact newCase = new contact();
JSONParser jParser = JSON.createParser(example);
/*CAN SOME ONE PLEASE HELP ME PARSE THIS JSON*/
return newCase.Id;
}
}
public class testJSON{
public String Os{get; set;}
public String Origin{get; set;}
public ConfirmationJSON(){
this.Os = '';
this.Origin = '';
}
}
public class Mytest{
public testJSON example{get; set;}
}
Then deserialize it like this:
Mytest myTest = (Mytest)JSON.deserialize(example, Mytest.class);
testJSON test = myTest.example;
Hope this helps