Skip to main content
Hello,

I have an apex callout class and a future callout method where I am passing JsonInput of Account fields.

During integration testing, it was requested that any field without any value , should be returned as ' ' <just blank> and not as "Null".

I don't think we can pass ' ' <just blank> in JSON.

But I still gave it a shot and checked blank value before creating json input...

@InvocableMethod

public static void postAccountToSystem(List<Id> acctIds){

Account acc = [SELECT Name,Display_Name__c,

Bio_URL__c,Image_URL__c

FROM Account WHERE Id = :acctIds[0]];

if(acc.Display_Name__c == NULL){

acc.Display_Name__c = '';

}

if(acc.Bio_URL__c == NULL){

acc.Bio_URL__c = '';

}

if(acc.Image_URL__c == NULL){

acc.Image_URL__c = '';

}

String jsonInput = '{\n' +

' "displayName" : "'+acc.Display_Name__c+'",\n'+

' "bioUrl" : "'+acc.Bio_URL__c+'",\n'+

' "imageUrl" : "'+acc.Image_URL__c+'",\n'+

System.enqueueJob(new QueueableCall(jsonInput, acc.Id));

}

Although the code saved, I am getting an "Internal Server Error, Status Code= 500" everytiime I lauch the callout.

Does any one have an idea how I can make the blank value as ' ' and not as "Null".

Any help is appreciated.

Thanks! 

 
5 answers
  1. Jun 13, 2017, 6:02 PM
    Thanks enForcer for the response.

    But even your code is doing the same thing I did with for loop.

    Either way the error persists.. statuscode=500.
0/9000