You need to sign in to do that
Don't have an account?
Avinash A
how to pass Account object from rest callout to rest webservice, Please Help me..
In the given code below i am passing json string 'name' in to http post method.In the rest callout mthod i serialized Account object in to JSON String.When i try to deserislize it in HttpPost method Im getting JSON parser error, Can anyone Please Help Me??
//This is the rest webservice
@Httppost
Global static Account doPost(String name){
//System.debug(name);
Account tn=(Account)JSON.deserialize(name, Account.class);
insert tn;
return tn;
}
//This is the rest webservice
@Httppost
Global static Account doPost(String name){
//System.debug(name);
Account tn=(Account)JSON.deserialize(name, Account.class);
insert tn;
return tn;
}
Or you can do one thing, since in post method debug will not get captured.. you can use below trick to see what's coming in json.
I guess the problem is that you are setting everything in request body so you may need to something like below
I guess the above will work properly. Let me know if it helps.
Regards,
Ashish Kr.
All Answers
Hi Avinash,
Could you please post the json you are passing?
The json you are getting in the post method must follow the below structure.
If your json is not in the above form then you can use Json.deserializeUntyped method to create a map and then you can retireive the required parameters to create the account records.
Let me know if you need further help.
Regards,
Ashish Kr.
Account a=new Account (name='test account name');
String ac=JSON.serialize(a);
request1.setBody(ac);
system.debug(ac);
can you please help me using Json.deserializeUntyped method to create a map and retrive the required parameters.
I am getting this when i put DEBUG in the callout,
but if i put DEBUG in HttpPost ,its not getting executed..
Can you please help me out??
Im making callout from a different org. My Rest Web Service does exist in a different org.And I have followed proper authentication process .
Still getting error.Could u please assist.
Thank you
Or you can do one thing, since in post method debug will not get captured.. you can use below trick to see what's coming in json.
I guess the problem is that you are setting everything in request body so you may need to something like below
I guess the above will work properly. Let me know if it helps.
Regards,
Ashish Kr.