I develop an Apex REST web service in Salesforce and I would like to test it with Postman.
Unfortunately, I get an error message than I don't understand:
Expected JSON object to deserialize apex parameter from at [line:3, column:14]
This is the JSON I tr to send with postman:
{
"data": [
{
"attendantYear":"2014;2015;2016;2018;2019",
"birthDate":"1981-12-11",
"city":"New-York",
"country":"USA",
"email":"[email protected]",
"firstname":"Jean-Paul",
"itra":450,
"lastname":"Gus",
"salutation":"Mr."
}
]
}
And this is how looks like my apex web service:
@RestResource(urlMapping='/accounts/*')
global with sharing class ABT_WSAccounts{
@HttpPost
global static String upsertAccounts(String data){
String result;
System.debug('--- data : ' + data);
if(!String.isBlank(data)){
List<Account> accountsToUpsert = new List<Account>();
List<ABT_AccountInnerClass> sobjects = (List<ABT_AccountInnerClass>) JSON.deserialize(data, List<ABT_AccountInnerClass>.class);
System.debug('--- sobjects : ' + sobjects);
.....
}
return result;
}
}
And my inner class:
global class ABT_AccountInnerClass{
global String firstname;
global String lastname;
global String salutation;
global Date birthDate;
global String email;
global String street;
global String country;
global String attendantYear;
global Decimal itra;
}
Please, can you explain me the error?
Thanks