Integrator > Integration Builder >   Integration inputs

Integration inputs

The request object describes the HTTP request posted to the integration service URL. You can use the transformation scripts to access the request headers, parameters, body, etc. The easiest way to examine the content of an incoming request is to send an HTTP request to your integration and then view the details in the Activity Stream.

Request object properties
Property Description

This is the body of the request posted to the integration service URL, and usually contains the JSON or XML payload of an HTTP POST.

  • If the body contains JSON, you can use JSON.parse(request.body) in the script to convert it to a JavaScript object.
  • If the body contains XML, you can use one of the included XML libraries to manipulate the data.
headers The HTTP headers of the incoming request. Note the Content-Type parameter that defines the payload type.

A JavaScript object featuring key-value pairs for any querystring parameters

If the Content-Type in the header is application/x-www-form-urlencoded, this section also contains the POST body parameters.

requestId The unique identifier (UUID) assigned to this request by the integration service when the request is received. This identifier is returned in the response, making it possible to match a request with the results of the script processing.

An xMatters internal use ID that allows tracking of the request through the system.

The following is a sample request object:

	"body": "<incident importance=\"High\">\n    <ticket>16931</ticket>\n    <summary>Mail server is down</summary>\n    <recipients>\n        <username>bsmith</username>\n        <username>mmcbride</username>\n    </recipients>\n</incident>",
	"headers": {
		"Accept": "*/*",
		"Authorization": "Basic lmht9e46Yo9tc3xleA==",
		"Content-Length": "217",
		"Content-Type": "application/xml",
		"Host": "",
		"User-Agent": "curl/7.40.0"
	"method": "POST",
	"parameters": {},
	"remoteAddr": "",
	"requestId": "afc9498a-ba47-418b-912f-d977091b7d2a",
	"timestamp": 1440001619011,
	"url": "",
	"xtrace": "afc9498a-ba47-418b-912f-d977091b7d2a"

If the body of your incoming request contains JSON, you can parse it to a JavaScript object using JSON.parse(request.body). If your incoming payload is XML, you may need to use one of the XML libraries listed below to read or manipulate the content.

Working with XML

The Integration Builder includes the following libraries that allow you to manipulate XML payloads. These are pure-JavaScript libraries sourced from "npm" (the package manager for Node.js), and packaged for use by the Nashorn engine using "browserify".

Library Description

This is an implementation of the W3C DOM parser specification. The source library is XMLDOM (

The DOMParser is a low-level parser used by the JXON and xpath libraries below, but can also be used directly.

XMLUtils.xpath This library allows you to read values from an XML DOM using the xpath syntax. The source library is xpath (

This library can be used to convert an XML document object into a native JavaScript object for further manipulation. The source library is jxon (

The Integration Builder provides a simplifying wrapper object for XMLUtils.JXON that takes an XML-formatted string and returns a JavaScript object using a single method, parse.

The wrapper takes this:

var obj = XMLUtils.DOMParser().parseFromString(xml));

And allows you to do this:

var obj = JXON.parse(xml);

By default, JXON case-folds all tag and attribute names to lowercase. For example, both <username> and <USERNAME> would be converted to a property called username in the JavaScript. To retain the exact case of tags and attributes, enable the following option in the script prior to calling JXON.parse:

XMLUtils.JXON.config({'lowerCaseTags': false});


The following examples illustrate how to use the included libraries to manipulate incoming XML payloads.

Incoming XML Manipulation
<incident importance="High">
    <summary>Mail server is down</summary>

Using DOMParser

var xml = request.body;
var doc = new XMLUtils.DOMParser().parseFromString(xml);['Incident ID'] = doc.getElementsByTagName("ticket")[0]; = doc.getElementsByTagName("summary")[0];
var recipients = [];
var recips = doc.getElementsByTagName("username");
for (var i = 0; i < recips.length; i++) {
    recipients.push({"targetName": recips.item(i)});
trigger.recipients = recipients;
trigger.priority = doc.getElementsByTagName("incident")[0].getAttribute("importance");;

Using xpath:

var str = request.body;
// Build the XML document from the request
var doc = new XMLUtils.DOMParser().parseFromString(str, 'text/xml');
// Get the ticket number
var ticket ='//ticket/text()', doc)[0].data;['Incident ID'] = ticket;
console.log("Ticket: " + ticket);
// Get the summary
var summary ='//summary/text()', doc)[0].data; = summary;
console.log("Summary: " + summary);
// Loop over the recipients objects
var recipients ='//recipients/username', doc);
for (var i in recipients) {
    var recipientUsername = recipients[i];
    console.log("Adding recipient " + recipientUsername);
// Get the priority
var importance ='//incident/@importance', doc)[0].value;
console.log("Priority: " + importance);
trigger.priority = importance;
// Post the trigger to the form;

Using JXON:

var xml = request.body;
var obj = JXON.parse(xml);
/* The following data gets logged:
    "incident": {
        "@importance": "High",
        "recipients": {
            "username": [
        "summary": "Mail server is down",
        "ticket": 1234    }
var data = obj.incident;['Incident ID'] = data.ticket; = data.summary;
var recipients = [];
for (var i in data.recipients.username) {
    recipients.push({"targetName": data.recipients.username[i]});
trigger.recipients = recipients;
trigger.priority = data['@importance'];;
         <sch:clientTimestamp xsi:nil="true"
         <sch:clientIP xsi:nil="true"
         <sch:clientOSUser xsi:nil="true"
               <sch:name>Incident ID</sch:name>
               <sch:value>testing SOAP endpoint</sch:value>

Using xpath with namespace:

var doc = new XMLUtils.DOMParser().parseFromString(request.body);
var select = XMLUtils.xpath.useNamespaces({"sch": ""});
var tokens = select('//sch:eventTokens/sch:eventToken', doc);
// Iterate the event tokens to build the form properties
for (var i in tokens) {
  var nameToken = select('sch:name/text()', tokens[i])[0].data;
  var valueToken = select('sch:value/text()', tokens[i])[0].data;
  console.log("Adding property: " + nameToken + " = " + valueToken);[nameToken] = valueToken;
// Extract the target name from the incoming request and add to the trigger
var targetName = select('//sch:user/text()', doc)[0].data;
console.log("Adding Recipients: " + targetName);
var recipients = [];
    'targetName': targetName
trigger.recipients = recipients;
// Post the form to xMatters;