+ Start a Discussion
Srinivasa Rayapuri 2Srinivasa Rayapuri 2 

"Error while deserializing: N/A at [line:1, column:2242]"

Hi 

I have a REST Class exoposed from salesforce is used to create an Account and Contact from a web form elsewhere in the company. 

It was working fine until 2 days ago and now i have the error (in description). 

Can anyone please help me understabd why?

Thanks in Advance
Sri
Mukesh_SfdcDevMukesh_SfdcDev
Hi ,

What type of error are you getting?
explain the little bit.

Thanks
Mukesh Kumar
Srinivasa Rayapuri 2Srinivasa Rayapuri 2
Hi Mukesh 

The only error i get, when the API is inserting a record into salesforce is this "Error while deserializing: N/A at [line:1, column:2242]" and the column number is not same all the time; meaning 
Insert 1 -> Error while deserializing: N/A at [line:1, column:1123]
insert 2 -> Error while deserializing: N/A at [line:1, column:2324]
Insert 3->  Error while deserializing: N/A at [line:1, column:1748]

There is an application form hosted on a website and when someone fills the information and clicks on Submit, it creates records (Account & Contact) in salesforce. 

This is the API Class 
@RestResource(urlMapping='/AccountContactWebService/*')
global with sharing class AccountContactWebService
{
    global static string strExecStepsJson='';
    static string sPersonEmail ='';
    
    @HttpPost
    /* This method Accepts the json Request from hantec forms and parse the data*/ 
    global static string createRecords() 
    {  
        
        String jsonStr ='';
        String strResponseFinal;
        
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        
        System.debug(req.requestBody);
       
        if(req!=null && req.requestBody!=null) jsonStr = req.requestBody.toString();
        system.debug('jsonstr ===>'+jsonstr);
        
        if(jsonStr.startsWith('\"'))jsonStr = jsonStr.removeStart('\"');
        if(jsonStr.endsWith('\"')) jsonStr = jsonStr.removeEnd('\"');
        
        jsonStr = jsonStr.unescapeUnicode();
        
        system.debug('jsonstrfinal ===>'+jsonStr);
       
        CreateAccount.AccountWrapper deserializedJSONObj = new CreateAccount.AccountWrapper();
        
        Boolean isValidJSON = true;
        
     
        try{
            deserializedJSONObj = (CreateAccount.AccountWrapper)JSON.deserialize(jsonstr, CreateAccount.AccountWrapper.class);
            System.debug('deserializedJSONObj=='+deserializedJSONObj);
            system.debug('****into accepting  root****'+ deserializedJSONObj);                        
        }catch (Exception ex){
            isValidJSON = false;
            System.debug('error: '+ex);   
            
            JSON_Logs__c log = new JSON_Logs__c();
            log.Reason__c = 'Error while deserializing: ';
            log.Full_Error_Log__c =  ex.getMessage();
            strResponseFinal = 'Error while deserializing: ' + ex.getMessage();
   
            try{
                insert log;
            }
            catch(Exception exc)
            {
                system.debug('====exception====>>'+exc.getMessage());
            }            
        }           
        

        if(isValidJSON == true) strResponseFinal = CreateAccount.createAcc(deserializedJSONObj);
        system.debug('****strResponseFinal****'+strResponseFinal);       
        return strResponseFinal;
    }
}



Now i am trying to find out whats causing the deseriaisation error.

Thanks

 
SFDC Dev1 13SFDC Dev1 13
@Srinivasa Rayapuri 2
Were you able to resolve this issue? i'm having the same issue, i posted here
https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005QHTQA2