Accessing HTTP content from a programme

Many of the steps allow you to configure javascript functions as part of the step. A number of standard methods/object are available in steps.

To call external APIs, use HTTPClient

The buildHttpClient takes two parameters which are used for a username and password for basic auth against an end point.

The result contains the following properties: 

  • responseBody: the response coming back from the server.
  • httpStatusCode: the status code (integer) coming back from the server.
  • responseHeaders: a string (which can be parsed as JSON) containing a list of key, value pairs for the response headers.
function getData(data) {
	var getCategory = function(sku) {
		var skuURL = '' + sku;
		var requester = httpClientFactory.buildHttpClient('', '');
		try {
			var result = requester.get(skuURL, {});
			if (result && result.responseBody) {
				var s = JSON.parse(result.responseBody);
				var headers = JSON.parse(result.responseHeaders);
				return s.category;
		} catch (e) {;
	var sku = data.__trigger['PURCHASED ITEM'].SKU;
	var cat = getCategory(sku);
	return {
		category: cat

We can then query the api via the following methods:

- get

- post

- put

Still need help? Contact Us Contact Us