+ Start a Discussion
pranav shah 40pranav shah 40 

Json Parse Error for Web Services

Hi All,

I am getting following error for my class:
Unexpected parameter encountered during deserialization: name at [line:2, column:9]

below is my code for same.
i am trying to insert account name thrugh workbench
 global with sharing class NewCustCreation
    //public String Status {get;set;}
    //public List<Account> Data {get;set;}
    //public String Message {get;set;}
    //public String ErrorCode {get; set;}
     public class Account

        public String Name;

    global static String dopost(String Name)
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response; 
         Account account =  new Account();
         String success = 'Welcome to Salesforce';
         String error = 'Error';
         if(Name!= '')
              return Name;
              return error;   

    public static NewCustCreation parse(String json)
        return (NewCustCreation) System.JSON.deserialize(json, NewCustCreation.class);

Request Body:
"name":"Eniig Customer"
Best Answer chosen by pranav shah 40
SandhyaSandhya (Salesforce Developers) 

Iam not sure if this the problem but your request body must be 
"Name":"Eniig Customer"

Capital N should be used.

Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.

Best Regards,