• sfdc learner 122
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi Team , i need help in fixing this test class

Wrapper Class:

public class AccountWrapper {
    public List<accRecords> AccountList;
  public  class accRecords {
    public String AccId;  
    public String NextVal;  
  }
  public static AccountWrapper parse(String json){
    return (AccountWrapper) System.JSON.deserialize(json, AccountWrapper.class);
  }

}

My Apex Snippet:

 Map<Id,String> accMap = new Map<Id,String>();
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String bodyJson = req.requestBody.toString();
AccountWrapper reqJSON = AccountWrapper.parse(bodyJSON);
for(AccountWrapper.accRecords acc : reqJSON.AccountList){
accMap.put(acc.AccId,acc.NextVal);
}

My test class is failing above highlighted line,i want to pass list of Account id in JsonBody 

currently i am facing below error message
System.JSONException: Malformed JSON: Expected '{' at the beginning of object  - i think this is i am passing single record