Discussion:
How to call a One HTTP Client Connector in another connector in Add/Update Successful Hooks.
(too old to reply)
Satish Jogi
2019-06-11 18:10:03 UTC
Permalink
Hi All,

I am trying to call one of the HTTP Client Connector in another Connector Add/Update Hooks. Kindly help me to provide some hints, so that i will try to complete.

Regards,
Satish J
Satish Jogi
2019-06-11 18:40:19 UTC
Permalink
Post by Satish Jogi
Hi All,
I am trying to call one of the HTTP Client Connector in another Connector Add/Update Hooks. Kindly help me to provide some hints, so that i will try to complete.
Regards,
Satish J
Thanks, i have used the below script to call another connector.

var httpConn = system.getConnector("ibmdi.HTTPClient");
httpConn.initialize(UpdateUser);
Eddie Hartman
2019-06-12 19:34:54 UTC
Permalink
Post by Satish Jogi
Post by Satish Jogi
Hi All,
I am trying to call one of the HTTP Client Connector in another Connector Add/Update Hooks. Kindly help me to provide some hints, so that i will try to complete.
Regards,
Satish J
Thanks, i have used the below script to call another connector.
var httpConn = system.getConnector("ibmdi.HTTPClient");
httpConn.initialize(UpdateUser);
Nice, Satish. I do all my http work from script like you're doing now. Note that .initialize() works just as well with null passed as the argument. If you want the connector to be pre-configured then you create it in the Resources > Connectors folder and give the name in the getConnector() call. Easy as spitting.

Furthermore, I often set parameters based on properties, and sometimes via script:

httpConn.setParam("url", "https://....");

Of course, if you use the CallReply mode function of the Connector Interface (which only a few Connectors implement) then you can pass in an Entry object when the call is made. This can contain attributes named appropriately:
----
request = system.newEntry();
request["http.body"] = toJson(someJSObject);
request["http.accept = "application/json";
request["http.content-type"] = "application/json";
request["http.method"] = "POST";
request["http.url"] = "https://...";
response = httpConn.queryReply(request); // queryReply() is the CallReply CI function
----
Then the call uses these attribute values. You have to use bracket-notation to specify these variables since they have special characters in the name. Otherwise you could standard dot-notation:
----
work.cn = "Roger Rabbit";
work.sn = "Rabbit";
----
And I never attach a Parser to the HTTP Connectors. I grab the http.bodyAsString attribute (always returned as a string, regardless of Content-Type specifier) and parse it myself. Let me know if you want any tips on this.

/Eddie

Loading...