Expand my Community achievements bar.

SOLVED

Error Rest Call Response

Avatar

Level 2

Hi everybody,

I am trying to do a Rest call to an existing API using a JS activity. The URL was already whitelisted by Adobe Campaign support team. The problem is that I am getting error -60, I dont know why because the same call is working fine using postman. Any idea?

 

var conf = {
"reqValue1": "value1",
"reqValue2": "value2",
"reqValue3": "value3",
"reqValue4": "value4",
"reqValue5": "value5"
};


var http = new HttpClientRequest("https://somehost:1111/ProdURL");
http.header["Content-Type"] = "application/json";
http.method = "POST"
http.header["Authorization"] = "Basic myToken";
// http.header["UserName"] = "someUser";
//http.header["Password"] = "someValue";

try
{
http.body = JSON.stringify(conf));
logInfo('Request: ' + conf);
http.execute();
logInfo("Finished Call : ");
var Rsp = JSON.parse(http.response.body.toString());

logInfo(" resp : "+Rsp);

}
catch(e)
{
logInfo(e.toString());
}

I can not see my message "Finished Call " , it throws the -60 error

 

1 Accepted Solution

Avatar

Correct answer by
Level 5

Try curl to do the call:

 

 

var conf= {
reqValue1: "req1value",
reqValue2: "req2value",
...
}

var payload = JSON.stringify(conf);

var curlURL = 'curl -s -H "Authorization: Basic ' + mytoken + '" -H "Content-Type: application/json;charset=utf-8" -d \'' + payload + '\' -X POST ' + urlpath;

var response = execCommand(curlURL, true);

 

View solution in original post

6 Replies

Avatar

Level 5

Hi Abraham92,

you can try passing the http.body as a string instead of using the function JSON.stringify. 

 

http.body='{"reqValue1": "value1","reqValue2": "value2","reqValue3": "value3","reqValue4": "value4","reqValue5": "value5"}';

Avatar

Level 2

Hi Richac,

 

I tried what you mentioned, but I am getting the same result. If I print the complete http object, on the body part I can see something like this:

{"body":"{\"reqValue1\":\"value1\",\"reqValue2\":\"value2\",\"requValue3\":\"value3\",\"reqValue4\":\"value4\",\"reqValue5\":\"value5\"}"

Avatar

Correct answer by
Level 5

Try curl to do the call:

 

 

var conf= {
reqValue1: "req1value",
reqValue2: "req2value",
...
}

var payload = JSON.stringify(conf);

var curlURL = 'curl -s -H "Authorization: Basic ' + mytoken + '" -H "Content-Type: application/json;charset=utf-8" -d \'' + payload + '\' -X POST ' + urlpath;

var response = execCommand(curlURL, true);

 

Avatar

Level 2
I tried using curl as you mentioned and I am getting : "couldnt connect to host", do you think this is because adobe team needs to whiteliste the URL ?

Avatar

Level 5
Hi... depends on if you've an hosted ACC or on-prem... for hosted ACC, you can configure it in the ACC control panel on your Experience Cloud. For on-prem you need to add it to the urlPermission

Avatar

Level 5
Hi... depends on if you've an hosted ACC or on-prem... for hosted ACC, you can configure it in the ACC control panel on your Experience Cloud. For on-prem you need to add it to the urlPermission in serverConf.xml.