You need to sign in to do that
Don't have an account?
Rest Resource
Hi,
I have created Rest resource class to accept json(POST Method) from php.
@RestResource(urlmapping='/JsonService/*')
global class AttorneyAdapter{
@HttpPost
global static void doPost() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
string strJSON = req.requestBody.toString();
JSONparser parser = JSON.createParser(strJSON);
Type reqObj = Type.forName('MyClass');
MyClass myClassObj =(MyClass)parser.readValueAs(reqObj);
lead l=new lead();
l.lastname=myClassObj.last_name;
l.firstname=myClassObj.first_name;
l.title=myClassObj.userid;
l.state=myClassObj.state;
l.company=myClassObj.firm_name;
insert l; } }
getting error:
message: "System.JSONException: No content to map to Object due to end of input (System Code) Class.AttorneyAdapter.doPost: line 15, column 1
Help me....
thanks,
Raviteja
Srirama10 - There is no need to make use of the parser here. Just build the doPost method with parameters that match the json attributes. For e.g.
The mapping should be handled by SFDC and no explicit serialization is required. HTH
try changing "Content-Type" to application/json