More details on HttpClientRequest

Avatar

Avatar
Give Back 5
Level 3
guillermoL
Level 3

Likes

17 likes

Total Posts

61 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile

Avatar
Give Back 5
Level 3
guillermoL
Level 3

Likes

17 likes

Total Posts

61 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile
guillermoL
Level 3

04-07-2017

Hi,

I am trying to make a remote call with HttpClientRequest to reach a Web Service. I can see that the http request is made (both POST or GET seems to work ok ), but I am finding some troubles to:

- Get the content of the response itself that is returned from the server. I can not even find the response headers.

- Also, I don't know how to deal with http Basic authentication. Should I set some particular headers?

Do you know of any reference or some help that I can use to !work out both topics below?

Thanks very much in advance

Guillermo

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
Level 6
David__Garcia
Level 6

Likes

106 likes

Total Posts

214 posts

Correct reply

44 solutions
Top badges earned
Coach
Builder
Engage 10
Seeker
Bedrock
View profile

Avatar
Coach
Level 6
David__Garcia
Level 6

Likes

106 likes

Total Posts

214 posts

Correct reply

44 solutions
Top badges earned
Coach
Builder
Engage 10
Seeker
Bedrock
View profile
David__Garcia
Level 6

05-07-2017

Try the following

var http = new HttpClientRequest("yourhost.com")

http.execute()

var response = http.response

for(var i in response.header)

  logInfo("header[" + i + "] => " + response.header[i])

Should give you something like

Answers (8)

Answers (8)

Avatar

Avatar
Springboard
MVP
Amit_Kumar
MVP

Likes

329 likes

Total Posts

649 posts

Correct reply

231 solutions
Top badges earned
Springboard
Ignite 5
Ignite 3
Ignite 1
Validate 10
View profile

Avatar
Springboard
MVP
Amit_Kumar
MVP

Likes

329 likes

Total Posts

649 posts

Correct reply

231 solutions
Top badges earned
Springboard
Ignite 5
Ignite 3
Ignite 1
Validate 10
View profile
Amit_Kumar
MVP

05-07-2017

You should use the following:

var API = 'http://yourwebserviceendpoint.com'

var http = new  HttpClientRequest(API);

http.method = "GET";

http.header["Content-Type"] = "application/json";

http.header["Accept"] = "application/json";

http.header["Authorization"] = "Basic Z3XNlbmRleHRlc3QxQGdtYWlsLmNvbTpsb2dpbjEyMzQ="; // replace with your authorization code

http.execute();

var response = http.response;

Regards,

Amit

Avatar

Avatar
Coach
Level 6
David__Garcia
Level 6

Likes

106 likes

Total Posts

214 posts

Correct reply

44 solutions
Top badges earned
Coach
Builder
Engage 10
Seeker
Bedrock
View profile

Avatar
Coach
Level 6
David__Garcia
Level 6

Likes

106 likes

Total Posts

214 posts

Correct reply

44 solutions
Top badges earned
Coach
Builder
Engage 10
Seeker
Bedrock
View profile
David__Garcia
Level 6

22-05-2019

Marcel, you must white list outbound url that you will be making the request to.

OCT -31- 2017 Campaign v6/v7 - 17.4 Build 8863

Technical evolutions

URL permissions

We have limited the default list of URLs that can be called by JavaScript codes (workflows, etc.). To allow a new URL, the administrator needs to reference it in the serverConf.xml file.

<urlPermission action="blocking" debugTrace="true"> <url dnsSuffix="abc.company1.com" urlRegEx="https://.*" /> <url dnsSuffix="def.partnerA_company1.com" urlRegEx="https://.*" /> <url dnsSuffix="xyz.partnerB_company1.com" urlRegEx="https://.*" /> </urlPermission> 

Refer to the Security configuration checklist for more information.

Avatar

Avatar
Give Back 5
Level 3
guillermoL
Level 3

Likes

17 likes

Total Posts

61 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile

Avatar
Give Back 5
Level 3
guillermoL
Level 3

Likes

17 likes

Total Posts

61 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile
guillermoL
Level 3

22-05-2019

Hi Marcel,

I don't think you need to add any authorization as far as I remember but I'm not 100% sure to be honest.

Regards

Guillermo

Avatar

Avatar
Springboard
MVP
MarcelSzimonisz
MVP

Likes

103 likes

Total Posts

227 posts

Correct reply

56 solutions
Top badges earned
Springboard
Establish
Contributor
Give Back 25
Give Back 10
View profile

Avatar
Springboard
MVP
MarcelSzimonisz
MVP

Likes

103 likes

Total Posts

227 posts

Correct reply

56 solutions
Top badges earned
Springboard
Establish
Contributor
Give Back 25
Give Back 10
View profile
MarcelSzimonisz
MVP

22-05-2019

Hello fellow campaigners,

can we send http request without authorizing the domains in the config?

I need to ping urls from JS activity

Avatar

Avatar
Give Back 5
Level 3
guillermoL
Level 3

Likes

17 likes

Total Posts

61 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile

Avatar
Give Back 5
Level 3
guillermoL
Level 3

Likes

17 likes

Total Posts

61 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile
guillermoL
Level 3

05-07-2017

Thanks Amit, works like a charm.

Regards

Guillermo

Avatar

Avatar
Give Back 5
Level 3
guillermoL
Level 3

Likes

17 likes

Total Posts

61 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile

Avatar
Give Back 5
Level 3
guillermoL
Level 3

Likes

17 likes

Total Posts

61 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile
guillermoL
Level 3

05-07-2017

Thanks David. I was trying to see the contents of the object returned with

JSON.stringify(response)

and did not get any output. Now with your help I am receiving what I was expecting.

Is anyone able to help with the http Basic authentication headers?

Avatar

Avatar
Give Back 5
Level 3
guillermoL
Level 3

Likes

17 likes

Total Posts

61 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile

Avatar
Give Back 5
Level 3
guillermoL
Level 3

Likes

17 likes

Total Posts

61 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Validate 10
View profile
guillermoL
Level 3

04-07-2017

Thanks David,

Actually this is what I was doing to make the request I meant before, but in the response I can not find anything related to the reply from the server.

Avatar

Avatar
Coach
Level 6
David__Garcia
Level 6

Likes

106 likes

Total Posts

214 posts

Correct reply

44 solutions
Top badges earned
Coach
Builder
Engage 10
Seeker
Bedrock
View profile

Avatar
Coach
Level 6
David__Garcia
Level 6

Likes

106 likes

Total Posts

214 posts

Correct reply

44 solutions
Top badges earned
Coach
Builder
Engage 10
Seeker
Bedrock
View profile
David__Garcia
Level 6

04-07-2017

Play around with this in a workflow, you'll get the idea.