Contact Free trial Login

ServiceNow Example - Mule 4

Get a ServiceNow Incident Record

This example creates a Mule flow that retrieves a record based on an incident number.

  1. Create a Mule application as a project.

  2. Add and configure an HTTP Listener as a trigger for your flow, and set a path such as this one:


    Optionally, use the default configuration for the HTTP Listener connection.

  3. After the HTTP Listener, add the Invoke operation from the ServiceNow connector to your flow.

  4. Set up and test a ServiceNow configuration for the connection to the ServiceNow server, for example:

    • Configuration Name: My ServiceNow Config

    • Username: my_user_name

    • Password: my_password

    • Service Address:

    • ServiceNow Version: Istanbul

    If the connection test is unsuccessful, correct any invalid connection parameters and retest the connection.

  5. In the Transport tab for the ServiceNow configuration, set up, test, and save a Basic Auth HTTP Message Dispatcher provider with the same username and password that you provided within the General tab, for example:

    • Username: my_user_name

    • Password: my_password

    If the connection test is unsuccessful, correct any invalid connection parameters and retest the connection.

  6. Select the Web Service Configuration values for the ServiceNow connector, for example:

    • Service: incident

    • Operation: getRecords

    Make sure that the values are available as menu items in the Service and Operation fields. The names become available once the connector loads the metadata for them. Do not type the names manually.

  7. Provide a transformation script for the connector.

    In your Invoke operation in Design Center, click the Map button for the Body field, click the Script tab at the bottom of the Body window, and paste a transformation script like this one:

    %dw 2.0
    output application/xml
    ns inc
        inc#getRecords: {
            inc#number: "INC0012345"

    Note that this example changes the output data type to application/xml.

  8. Add a Logger to the end of your flow that takes payload as the message.

  9. Deploy, sync, or run the app.

  10. To test the app, open from a browser or from an app such as Postman.

    The response should look something like this (many fields are omitted for brevity):

    <getRecordsResponse xmlns:xsd="" xmlns:xsi="">
        <approval>not requested</approval>
        <opened_at>2017-07-27 03:13:54</opened_at>
        <short_description>Server outage</short_description>
        <sys_created_on>2017-07-27 03:14:52</sys_created_on>

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.