Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I am calling an API of FluidSurvey. When I make a POST request ... it post the request on the fluidSurvey but I didn't get the JSON response. rather it returns nothing. any suggestion??

my controller code

public class fluidSurvey{

public String tst{set;get;}

public String result{get;set;}

public PageReference chk() {


    return null;


public void getData(){

    String apiKey = 'xxxxxx';

    String pwd = 'xxxxxx';

    String u = '';

    HttpRequest req = new HttpRequest();

    Http http = new Http();

    HTTPResponse res;





        Blob headerValue = Blob.valueOf(apikey + ':' + pwd);

        String authorizationHeader = 'Basic '+ EncodingUtil.base64Encode(headerValue);

        req.setHeader('Authorization', authorizationHeader);

        req.setHeader('Content-Type', 'application/json');


        res = http.send(req); 

        tst= res.toString();

       catch(Exception e){

           System.debug('Callout error: '+ e);





and the Apex page code is

<apex:page controller="fluidSurvey">

<apex:form >

    <apex:pageBlock title="New Fluid Surveys API">

    <apex:outputText value="{!tst}"></apex:outputText><br/>

<apex:pageBlockButtons location="bottom">

    <apex:commandButton value="Submit" action="{!chk}"/>




and API documentation link is

1 Answer

0 votes
by (32.1k points)
edited by

The problem with my code was that I setting a content-length header, but not setting anybody, the server is diligently waiting for the 3199-byte body. so after using the set body method my code properly returns a JSON response

Looking for a comprehensive Salesforce course? Enroll now!

Related questions

Browse Categories