Integrating ServiceNow with MuleSoft
Overview:
- ServiceNow is a premier IT Service Management (ITSM) platform that helps organizations automate workflows, manage incidents, and enhance service delivery.
- MuleSoft facilitates this integration through its ServiceNow Connector, which enables seamless interaction with ServiceNow’s REST APIs—allowing developers to easily create, retrieve, update, and delete records across modules like Incident, Change, Problem, and CMDB.
- By leveraging MuleSoft’s API-led architecture and the ServiceNow Connector, organizations can reduce manual intervention, improve data accuracy, and orchestrate unified workflows across systems—ultimately enhancing IT responsiveness and delivering greater business agility.
What is ServiceNow?
- ServiceNow is a leading cloud-based platform designed to help organizations manage digital workflows across various business functions. Originally known for transforming IT Service Management (ITSM), ServiceNow has evolved into a powerful enterprise solution that supports IT operations, HR, customer service, security, and more.
- At its core, ServiceNow provides a unified platform that enables businesses to automate routine tasks, streamline service delivery, and enhance visibility across departments. With its intuitive interface, low-code development tools, and a vast library of ready-to-use applications, ServiceNow empowers teams to innovate faster and operate more efficiently.
Key Features:
- Allow users to request services or support through an intuitive, user-friendly portal.
- Automate complex business processes across IT, HR, finance, and operations with drag-and-drop tools and threat response
- Use conversational AI to handle common service requests and reduce support workload.
- Enable rapid app creation with minimal coding using visual development tools.
Understanding Key Components of the ServiceNow Connector in MuleSoft
MuleSoft provides three essential components within its ServiceNow Connector to simplify and streamline integration with the ServiceNow platform:
Invoke
- The Invoke operation is a generic action used to call any ServiceNow API method.
- It enables you to execute custom REST API calls to ServiceNow beyond standard CRUD operations.
- Useful for calling ServiceNow scripted APIs, workflows, or other custom endpoints.
- Offers flexibility when out-of-the-box operations don’t meet your requirements.
Unauthorized
- When MuleSoft tries to connect to ServiceNow but the credentials or authentication tokens are invalid or expired, an Unauthorized error (HTTP 401) occurs.
- MuleSoft provides built-in error types like SERVICE_NOW:UNAUTHORIZED to catch these failures.
- You can use On Error Continue or On Error Propagate error handling scopes in Mule flows to gracefully handle unauthorized errors.
- Common practices include logging the error, retrying authentication, or notifying administrators.
-
On New / Updated Record
- ServiceNow does not provide native event triggers or webhooks for real-time push notifications.
- To detect new or updated records, MuleSoft typically uses a polling approach:
- Use the Scheduler component to run periodic queries on ServiceNow tables.
- Use the Query Table operation with filters on fields like sys_created_on (for new records) or sys_updated_on (for updates).
- Store the timestamp of the last poll in MuleSoft’s Object Store to avoid processing duplicates.
In this blog, we will walk through how to use MuleSoft’s ServiceNow Connector to perform essential ITSM (IT Service Management) operations:
- Create a Problem record
- Insert a new Incident
- Insert a Change Request
- Retrieve Incident records
Create a Problem Ticket:
A Problem ticket in ServiceNow represents the root cause of one or more incidents. It is created to investigate and resolve the underlying issues causing recurring incidents.
Steps:
- To begin, a new Mule project needs to be created. Then, a HTTP listener component dragged and dropped into the project from the HTTP module. Configure the listener, and set the host to All interface (0.0.0.0), port number as 8081. Set the path as /problem.
2. Following the addition of the listener component, include two loggers to mark the beginning and the end of the flow. By logging the message “Start of flow” ++ (flow.name as String), in expression mode.
3. Within the Mule Palette, use the search function in the exchange to look for the Servicenow connector and add it.
4. After adding the ServiceNow Connector, configure it by creating a global configuration that includes your ServiceNow credentials and connection details.
service=”problem” specifies the ServiceNow Problem service.
operation=”insert” means create a new record.
5. Next, we’ll add a Transform Message component before the servicenow invoke operation to convert the incoming JSON payload into the XML format required by the ServiceNow Problem API.
6. Add a transform message after invoke component to format the response into JSON format.
7. Provide a request to api and response will be provide mentioned below.
8. Check in Servicenow dashboard. Both sys_id and number are unique in Servicenow for Incident. Sys_id can be used to update an existing Incident Ticket.
Create an Incident:
An Incident in ServiceNow represents an unplanned interruption to an IT service or a reduction in the quality of an IT service. Creating incidents helps IT teams track and resolve issues efficiently.
Steps:
- Configure the listener with path — /incident and choose service as incident and operation- insert in invoke component.
- Add a Transform Message component before the servicenow invoke operation to convert the incoming JSON payload into the XML format required by the ServiceNow Problem API.
- Hit the request on the postman to the api and response will be provided as below.
4. Check in Servicenow dashboard. Both sys_id and number are unique in Servicenow for Incident. Sys_id can be used to update an existing Incident Ticket.
Create a Change Request:
A Change Request in ServiceNow is a formal proposal to modify any configuration item (CI), service, or system. It’s part of Change Management, helping organizations manage risk and ensure proper approvals before implementing IT changes.
Change Requests are classified into:
- Standard (pre-approved, low risk)
- Normal (requires assessment and approval)
- Emergency (expedited due to critical issues)
Steps:
- Configure the listener with path — /change and choose service as change_request and operation- insert in invoke component.
2. Add a Transform Message component before the servicenow invoke operation to convert the incoming JSON payload into the XML format required by the ServiceNow Problem API.
3. Hit the request on the postman to the api and response will be provided as below.
4. Check in Servicenow dashboard. Both sys_id and number are unique in Servicenow for Incident. Sys_id can be used to update an existing Incident Ticket.
Retrieve all Incidents:
We can fetch a list of incident records from ServiceNow
Steps:
- Configure the listener with path — /retrieve and choose service as incident and operation- getRecords in invoke component.
2. Add a Transform Message component before the servicenow invoke operation to convert the incoming JSON payload into the XML format required by the ServiceNow Problem API.
3. Hit the request on the postman to the api and response will be provided as below.
- We can see how many incidents we have created as below.
{
“headers”: {},
“attachments”: {},
“body”: {
“getRecordsResponse”: {
“getRecordsResult”: {
“active”: “1”,
“activity_due”: null,
“additional_assignee_list”: null,
“approval”: “not requested”,
“approval_set”: null,
“assigned_to”: “6816f79cc0a8016401c5a33be04be441”,
“assignment_group”: “cfcbad03d711110050f5edcb9e61038f”,
“business_duration”: null,
“business_impact”: null,
“business_service”: null,
“business_stc”: “0”,
“calendar_duration”: null,
“calendar_stc”: “0”,
“caller_id”: null,
“category”: “inquiry”,
“cause”: null,
“caused_by”: null,
“child_incidents”: “0”,
“close_code”: null,
“close_notes”: null,
“closed_at”: null,
“closed_by”: null,
“cmdb_ci”: null,
“comments_and_work_notes”: null,
“company”: null,
“contact_type”: null,
“contract”: null,
“correlation_display”: null,
“correlation_id”: null,
“delivery_plan”: null,
“delivery_task”: null,
“description”: “Creating a incident”,
“due_date”: null,
“escalation”: “0”,
“expected_start”: null,
“follow_up”: null,
“group_list”: null,
“hold_reason”: “0”,
“impact”: “3”,
“incident_state”: “2”,
“knowledge”: “0”,
“location”: null,
“made_sla”: “1”,
“notify”: “1”,
“number”: “INC0010002”,
“opened_at”: “2025-06-07 10:21:42”,
“opened_by”: “6816f79cc0a8016401c5a33be04be441”,
“order”: “0”,
“origin_id”: null,
“origin_table”: null,
“parent”: null,
“parent_incident”: null,
“priority”: “5”,
“problem_id”: null,
“reassignment_count”: “1”,
“reopen_count”: “0”,
“reopened_by”: null,
“reopened_time”: null,
“resolved_at”: null,
“resolved_by”: null,
“rfc”: null,
“route_reason”: “0”,
“service_offering”: null,
“severity”: “3”,
“short_description”: “Hello incident”,
“sla_due”: null,
“state”: “2”,
“subcategory”: null,
“sys_class_name”: “incident”,
“sys_created_by”: “admin”,
“sys_created_on”: “2025-06-07 10:21:42”,
“sys_domain”: “global”,
“sys_domain_path”: “/”,
“sys_id”: “0b5203ecc38e2210c366ffbc05013131”,
“sys_mod_count”: “1”,
“sys_updated_by”: “admin”,
“sys_updated_on”: “2025-06-07 10:22:45”,
“task_effective_number”: “INC0010002”,
“time_worked”: null,
“universal_request”: null,
“upon_approval”: “proceed”,
“upon_reject”: “cancel”,
“urgency”: “3”,
“user_input”: null,
“watch_list”: null,
“work_end”: null,
“work_notes_list”: null,
“work_start”: null
},
“getRecordsResult”: {
“active”: “1”,
“activity_due”: null,
“additional_assignee_list”: null,
“approval”: “not requested”,
“approval_set”: null,
“assigned_to”: null,
“assignment_group”: null,
“business_duration”: null,
“business_impact”: null,
“business_service”: null,
“business_stc”: “0”,
“calendar_duration”: null,
“calendar_stc”: “0”,
“caller_id”: null,
“category”: “inquiry”,
“cause”: null,
“caused_by”: null,
“child_incidents”: “0”,
“close_code”: null,
“close_notes”: null,
“closed_at”: null,
“closed_by”: null,
“cmdb_ci”: null,
“comments_and_work_notes”: null,
“company”: null,
“contact_type”: null,
“contract”: null,
“correlation_display”: null,
“correlation_id”: null,
“delivery_plan”: null,
“delivery_task”: null,
“description”: “Creating a incident”,
“due_date”: null,
“escalation”: “0”,
“expected_start”: null,
“follow_up”: null,
“group_list”: null,
“hold_reason”: “0”,
“impact”: “3”,
“incident_state”: “1”,
“knowledge”: “0”,
“location”: null,
“made_sla”: “1”,
“notify”: “1”,
“number”: “INC0010001”,
“opened_at”: “2025-06-07 10:20:26”,
“opened_by”: “6816f79cc0a8016401c5a33be04be441”,
“order”: “0”,
“origin_id”: null,
“origin_table”: null,
“parent”: null,
“parent_incident”: null,
“priority”: “5”,
“problem_id”: null,
“reassignment_count”: “0”,
“reopen_count”: “0”,
“reopened_by”: null,
“reopened_time”: null,
“resolved_at”: null,
“resolved_by”: null,
“rfc”: null,
“route_reason”: “0”,
“service_offering”: null,
“severity”: “3”,
“short_description”: “Incident creation”,
“sla_due”: null,
“state”: “1”,
“subcategory”: null,
“sys_class_name”: “incident”,
“sys_created_by”: “admin”,
“sys_created_on”: “2025-06-07 10:20:26”,
“sys_domain”: “global”,
“sys_domain_path”: “/”,
“sys_id”: “2c128bacc38e2210c366ffbc050131c0”,
“sys_mod_count”: “0”,
“sys_updated_by”: “admin”,
“sys_updated_on”: “2025-06-07 10:20:26”,
“task_effective_number”: “INC0010001”,
“time_worked”: null,
“universal_request”: null,
“upon_approval”: “proceed”,
“upon_reject”: “cancel”,
“urgency”: “3”,
“user_input”: null,
“watch_list”: null,
“work_end”: null,
“work_notes_list”: null,
“work_start”: null
}
}
}
}