I'm trying to make API call to external system from a Cloud page, but when I publish I'm getting response Response:nullresultString:. Below the code details. Can someone please help me this. Thank you and looking forward to hear your inputs.

Code that put in Cloud page to make API call

<script runat=server>
Platform.Load("core", "1.1.1");

var accessToken = 'XXXXXXXX';
var clientid = 'KKKKKKKK';
var clientsecret = 'YYYYYYYYY';  

var url = 'https://endpointurl.com'

var payload = '{"requestHeader": {"consumer": {"name": "SFMC","id": "SFMC","businessUnit": "CUSTOMER PROFILING","type": "EXTERNAL","clientVersion": "V1","requestDateTime": "2018-07-28 22:27:56:048","hostName": "uapp9077n","businessTransactionType": "ProfileAndPreferenceWrapper","contextId": "","secondContextId": "","thirdContextId": ""},"credentials": {"userName": "","password": "","token": "aip_personalization","type": "jwt"},"transactionId": "31a1475d-0a64-467e-9933-5c928172d145"},"requestBody": {"preferences" :[{"phoneNumber": "565655656","isOptedIn": "false", "isImplicit": "true"}]}}';

  var auth = 'Basic ' + accessToken;
  var req = new Script.Util.HttpRequest(url);
  req.emptyContentHandling = 0;
  req.retries = 2;
  req.continueOnError = true;
  req.contentType = "application/json"
  req.setHeader("Authorization", auth);
  req.setHeader("x-ibm-client-id", clientid);
  req.setHeader("x-ibm-client-secret", clientsecret);
  req.method = "POST"; /*** You can change the method here ***/
  req.postData = payload;

  var resp = req.send();
  var resultString = String(resp.content)
  var resultJSON = Platform.Function.ParseJSON(String(resp.content));
   } catch (e) { Write(Stringify(e)) }

Here the curl that works in postman

curl --location --request POST 'https://endpointurl.com' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic XXXXXXXX' \
--header 'x-ibm-client-id: KKKKKKKK' \
--header 'x-ibm-client-secret: YYYYYYYYY' \
--data-raw '{
    "requestHeader": {
        "consumer": {
            "name": "SFMC",
            "id": "SFMC",
            "businessUnit": "CUSTOMER PROFILING",
            "type": "EXTERNAL",
            "clientVersion": "V1",
            "requestDateTime": "2018-07-28 22:27:56:048",
            "hostName": "uapp9077n",
            "businessTransactionType": "ProfileAndPreferenceWrapper",
            "contextId": "",
            "secondContextId": "",
            "thirdContextId": ""
        "transactionId": "31a1475d-0a64-467e-9933-5c928172d145"
    "requestBody": {
        "preferences": [
                "phoneNumber": "565655656",
                "isOptedIn": false,
                "isImplicit": true
  • 3
    Does this answer your question? Marketing Cloud API - External Integration Apr 29 at 6:56
  • Edited out your credentials. Apr 29 at 6:59
  • Put a try/catch around it (try { ...your code... } catch(e) { Write(Stringify(e)) } - need Core library called to use example as is) and see if you can get more details on the error. The most likely culprit I can see would be the payload as if there is a ' or something else that can malform the JSON string in it, it will blow up. I would recommend building it out as a JSON and then Stringifying it to push to payload. Apr 29 at 13:35
  • @Gortonington : I've update question. I did JSON stringify and put output as payload. Now the response I'm getting is Response:nullresultString: . Do you think is there something do with IP whitelisting or it's a code error.
    – Ramya
    Apr 30 at 19:38

1 Answer 1


This bit looks wrong:

var accessToken = {{yourAccessTokenWhichShouldNeverBePublicOnPagesLikeThis}}; 

Change it to:

var accessToken = 'yourAccessTokenWhichShouldNeverBePublicOnPagesLikeThis'; 
  • It did not work. I’ve updated the question with the error message.
    – Ramya
    May 1 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.