• Astrid Decker CFRA
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I have looked at this JSON issue for hours and can't figure out what I am missing that creates this error on certain occasions. So sometimes it works and sometimes it fails with following message:"Malformed JSON: Expected '{' at the beginning of object"

Here is the CallOutClass
/*****************************************************************************/
global class AccountNsCalloutClass 
{
@future(callout=true)
 global static void callRemote(Map<ID,String> oid,String operation)
 {
     if(operation=='UPDATE'){     
         System.debug('*************Apex UPdate Execution Started***************** ');
         List<Account> opl= [SELECT AccountSource,isTaxable__c,VAT__c,Fax,Email__c,Client_Class__c,Client_Tier__c,Subsidiary__c,Owner.Name,BillingAddress,BillingCity,BillingCountry,BillingGeocodeAccuracy,BillingLatitude,BillingLongitude,BillingPostalCode,BillingState,BillingStreet,CreatedDate,Description,Id,Industry,IsDeleted,Jigsaw, JigsawCompanyId,LastActivityDate,LastModifiedById,LastModifiedDate,LastReferencedDate,LastViewedDate,MasterRecordId,Name,NSCustomerId__c,NSInternalId__c,NumberOfEmployees,ParentId,Phone,PhotoUrl,ShippingAddress,ShippingCity,ShippingCountry,ShippingGeocodeAccuracy,ShippingLatitude,ShippingLongitude,ShippingPostalCode,ShippingState,ShippingStreet,SicDesc,SystemModstamp,Type,Website,Client_Type__c FROM Account WHERE ID IN:oid.keySet()];  
         List<Account> acc=new List<Account>();
         for(Account op:opl)
         {
             HTTPResponse resp=AccountNsCalloutClass.makeCallout(op,operation);
             system.debug('response@'+resp.getBody());
             AccountToJSONRES jres=(AccountToJSONRES)JSON.deserialize(resp.getBody(),AccountToJSONRES.class);   
         }
         }         
      }
 }
/*****************************************************************************/
And here is the JSON Class:
/*****************************************************************************/
public class AccountToNSJson {
     public String operationType{get;set;}
     public String AccountSource{get;set;}
     public String OwnerName{get;set;}
     public String BillingAddress{get;set;}
     public String BillingCity{get;set;}
     public String BillingCountry{get;set;}
     public String BillingGeocodeAccuracy{get;set;}
     public String BillingLatitude{get;set;}
     public String BillingLongitude{get;set;}
     public String BillingPostalCode{get;set;}
     public String BillingState{get;set;}
     public String BillingStreet {get;set;}
     public String CreatedDate{get;set;}
     public String Description{get;set;}
     public String SFDCAccountId {get;set;}
     public String Industry{get;set;}
     public String IsDeleted{get;set;}
     public String Jigsaw{get;set;}
     public String LastModifiedDate{get;set;}
     public String Name{get;set;}
     public String Salutation{get;set;}
     public String FirstName{get;set;}
     public String LastName{get;set;}
     public String MiddleName{get;set;}
     public String NetsuiteId{get;set;}
     public String NumberOfEmployees {get;set;}
     public String ParentId {get;set;} 
     public String Phone {get;set;}   
     public String PhotoUrl {get;set;}    
     public String ShippingAddress {get;set;}  
     public String ShippingCity {get;set;}   
     public String ShippingCountry {get;set;}    
     public String ShippingGeocodeAccuracy {get;set;} 
     public String ShippingLatitude {get;set;}   
     public String ShippingLongitude {get;set;}    
     public String ShippingPostalCode {get;set;} 
     public String ShippingState {get;set;}   
     public String ShippingStreet {get;set;} 
     public String Fax{get;set;}
     public String Mobile{get;set;}
     public String Title{get;set;}
     public String Email{get;set;}
     public String Subsidiary {get;set;}
     public String SicDesc {get;set;} 
     public String SystemModstamp {get;set;} 
     public String AccountType {get;set;} 
     public String Website {get;set;} 
     public String ClientClass {get;set;} 
     public String ClientTier {get;set;}
     public String ClientType {get;set;} 
     public String CurrencyCode {get;set;}
     public String IsTaxable {get;set;} 
     //AD 20190618 - add VAT#
     public String VAT {get;set;} 
}
/*****************************************************************************/

Thank you for your help!
I have looked at this JSON issue for hours and can't figure out what I am missing that creates this error on certain occasions. So sometimes it works and sometimes it fails with following message:"Malformed JSON: Expected '{' at the beginning of object"

Here is the CallOutClass
/*****************************************************************************/
global class AccountNsCalloutClass 
{
@future(callout=true)
 global static void callRemote(Map<ID,String> oid,String operation)
 {
     if(operation=='UPDATE'){     
         System.debug('*************Apex UPdate Execution Started***************** ');
         List<Account> opl= [SELECT AccountSource,isTaxable__c,VAT__c,Fax,Email__c,Client_Class__c,Client_Tier__c,Subsidiary__c,Owner.Name,BillingAddress,BillingCity,BillingCountry,BillingGeocodeAccuracy,BillingLatitude,BillingLongitude,BillingPostalCode,BillingState,BillingStreet,CreatedDate,Description,Id,Industry,IsDeleted,Jigsaw, JigsawCompanyId,LastActivityDate,LastModifiedById,LastModifiedDate,LastReferencedDate,LastViewedDate,MasterRecordId,Name,NSCustomerId__c,NSInternalId__c,NumberOfEmployees,ParentId,Phone,PhotoUrl,ShippingAddress,ShippingCity,ShippingCountry,ShippingGeocodeAccuracy,ShippingLatitude,ShippingLongitude,ShippingPostalCode,ShippingState,ShippingStreet,SicDesc,SystemModstamp,Type,Website,Client_Type__c FROM Account WHERE ID IN:oid.keySet()];  
         List<Account> acc=new List<Account>();
         for(Account op:opl)
         {
             HTTPResponse resp=AccountNsCalloutClass.makeCallout(op,operation);
             system.debug('response@'+resp.getBody());
             AccountToJSONRES jres=(AccountToJSONRES)JSON.deserialize(resp.getBody(),AccountToJSONRES.class);   
         }
         }         
      }
 }
/*****************************************************************************/
And here is the JSON Class:
/*****************************************************************************/
public class AccountToNSJson {
     public String operationType{get;set;}
     public String AccountSource{get;set;}
     public String OwnerName{get;set;}
     public String BillingAddress{get;set;}
     public String BillingCity{get;set;}
     public String BillingCountry{get;set;}
     public String BillingGeocodeAccuracy{get;set;}
     public String BillingLatitude{get;set;}
     public String BillingLongitude{get;set;}
     public String BillingPostalCode{get;set;}
     public String BillingState{get;set;}
     public String BillingStreet {get;set;}
     public String CreatedDate{get;set;}
     public String Description{get;set;}
     public String SFDCAccountId {get;set;}
     public String Industry{get;set;}
     public String IsDeleted{get;set;}
     public String Jigsaw{get;set;}
     public String LastModifiedDate{get;set;}
     public String Name{get;set;}
     public String Salutation{get;set;}
     public String FirstName{get;set;}
     public String LastName{get;set;}
     public String MiddleName{get;set;}
     public String NetsuiteId{get;set;}
     public String NumberOfEmployees {get;set;}
     public String ParentId {get;set;} 
     public String Phone {get;set;}   
     public String PhotoUrl {get;set;}    
     public String ShippingAddress {get;set;}  
     public String ShippingCity {get;set;}   
     public String ShippingCountry {get;set;}    
     public String ShippingGeocodeAccuracy {get;set;} 
     public String ShippingLatitude {get;set;}   
     public String ShippingLongitude {get;set;}    
     public String ShippingPostalCode {get;set;} 
     public String ShippingState {get;set;}   
     public String ShippingStreet {get;set;} 
     public String Fax{get;set;}
     public String Mobile{get;set;}
     public String Title{get;set;}
     public String Email{get;set;}
     public String Subsidiary {get;set;}
     public String SicDesc {get;set;} 
     public String SystemModstamp {get;set;} 
     public String AccountType {get;set;} 
     public String Website {get;set;} 
     public String ClientClass {get;set;} 
     public String ClientTier {get;set;}
     public String ClientType {get;set;} 
     public String CurrencyCode {get;set;}
     public String IsTaxable {get;set;} 
     //AD 20190618 - add VAT#
     public String VAT {get;set;} 
}
/*****************************************************************************/

Thank you for your help!