i am tring to insert list of account records using dto class...
list<dtoaccount> a = (list<dtoaccount>)JSON.deserialize(body.toString(),dtoaccount.class);
i used this code for converting json body here "dtoaccount" is Wrapperclass but i am getting error:
"errorCode": "APEX_ERROR", "message": "System.TypeException: Invalid conversion from runtime type accountinsertion.dtoaccount to List\n\nClass.accountinsertion.postaccount: line 11, column 1"
wrapper class:
public class dtoaccount{
public string name{get;set;}
public string Phone{get;set;}
public string type{get;set;}
public string Industry{get;set;}
public dtoaccount(string name,string Phone,string type,string Industry){
this.Name = Name;
this.Phone = Phone;
this.type = type;
this.Industry = Industry;
}
}
body:
{
"name":"xyz",
"Phone":"123456789",
"type" : "prospect",
"Industry" : "banking"
}
body.toString()
anddtoaccount
? so we can compare what is wrong.