Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Error Rest Call Response

Avatar

Avatar
Validate 1
Level 1
Abraham92
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
Abraham92
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
Abraham92
Level 1

17-02-2020

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

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 10
Level 4
stefanm38281801
Level 4

Likes

43 likes

Total Posts

51 posts

Correct Reply

2 solutions
Top badges earned
Validate 10
Contributor
Shape 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 10
Level 4
stefanm38281801
Level 4

Likes

43 likes

Total Posts

51 posts

Correct Reply

2 solutions
Top badges earned
Validate 10
Contributor
Shape 1
Give Back 5
Give Back 3
View profile
stefanm38281801
Level 4

25-02-2020

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);

 

Answers (1)

Answers (1)

Avatar

Avatar
Validate 10
Level 4
richac96395021
Level 4

Likes

32 likes

Total Posts

86 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 10
Level 4
richac96395021
Level 4

Likes

32 likes

Total Posts

86 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 25
View profile
richac96395021
Level 4

18-02-2020

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"}';