You need to sign in to do that
Don't have an account?
Astrid Decker CFRA
Malformed JSON: Expected '{' at the beginning of object
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!
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!
Can you please add JSON string ?
Thanks
jsonstr@{ "Website" : null, "VAT" : null, "Title" : null, "SystemModstamp" : "2019-08-23 13:12:32", "Subsidiary" : "US", "SicDesc" : null, "ShippingStreet" : "One Post Office Sqaure", "ShippingState" : "Massachusetts", "ShippingPostalCode" : "02109", "ShippingLongitude" : null, "ShippingLatitude" : null, "ShippingGeocodeAccuracy" : null, "ShippingCountry" : "United States", "ShippingCity" : "Boston", "ShippingAddress" : "System.Address[getCity=Boston;getCountry=United States;getCountryCode=US;getGeocodeAccuracy=null;getPostalCode=02109;getState=Massachusetts;getStateCode=MA;getStreet=One Post Office Sqaure;]", "SFDCAccountId" : "0014100000tPzSYAA0", "Salutation" : null, "PhotoUrl" : null, "Phone" : "1 (617) 292-1000", "ParentId" : null, "OwnerName" : "Brendan McAuley", "operationType" : "UPDATE", "NumberOfEmployees" : null, "NetsuiteId" : "1298", "Name" : "Putnam Investments, LLC", "Mobile" : null, "MiddleName" : null, "LastName" : null, "LastModifiedDate" : "2019-08-23 13:12:32", "Jigsaw" : null, "IsTaxable" : "true", "IsDeleted" : "false", "Industry" : null, "FirstName" : null, "Fax" : null, "Email" : null, "Description" : null, "CurrencyCode" : null, "CreatedDate" : "2017-09-25 03:48:44", "ClientType" : "Asset Management", "ClientTier" : null, "ClientClass" : null, "BillingStreet" : "One Post Office Square", "BillingState" : "Massachusetts", "BillingPostalCode" : "02109", "BillingLongitude" : null, "BillingLatitude" : null, "BillingGeocodeAccuracy" : null, "BillingCountry" : "United States", "BillingCity" : "Boston", "BillingAddress" : "System.Address[getCity=Boston;getCountry=United States;getCountryCode=US;getGeocodeAccuracy=null;getPostalCode=02109;getState=Massachusetts;getStateCode=MA;getStreet=One Post Office Square;]", "AccountType" : "Vote Customer", "AccountSource" : null }