How to setup integration between ServiceNow and LeanIX using GraphQL API
This content was last updated in 2024. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2024 05:08 PM
Hello, i have a requirement where i need to integrate between servicenow PDI and leanIX demo instance using GraphQL API.Whenever there is a record created in ServiceNow , a factsheet should be created on LeanIX end.Any leads would be appreciated.Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 07:58 AM
Hi @sarikab,
please check below step:
Set Up LeanIX GraphQL API:
- Obtain LeanIX API endpoint and authentication token.
- Familiarize with the GraphQL mutation to create a factsheet.
Create a Script Include in ServiceNow:
var LeanIXIntegration = Class.create();
LeanIXIntegration.prototype = {
initialize: function() {
this.endpoint = 'YOUR_LEANIX_API_ENDPOINT';
this.token = 'YOUR_LEANIX_API_TOKEN';
},
createFactSheet: function(record) {
var payload = {
query: `mutation {
createFactSheet(input: {
type: "YOUR_FACTSHEET_TYPE",
name: "${record.name}",
description: "${record.description}"
}) {
factSheet {
id
name
}
}
}`
};
var request = new sn_ws.RESTMessageV2();
request.setEndpoint(this.endpoint);
request.setHttpMethod('POST');
request.setRequestHeader('Authorization', 'Bearer ' + this.token);
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestBody(JSON.stringify(payload));
request.execute();
},
type: 'LeanIXIntegration'
};
Create a Business Rule in ServiceNow:
- Table: Specify the table (e.g., Incident, Task).
- When: After Insert.
(function executeRule(current, previous) {
var leanIX = new LeanIXIntegration();
leanIX.createFactSheet(current);
})(current, previous);
Thank you, please make helpful if you accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 08:09 AM
Hello @Yashsvi ,
Thanks for the response,
I have already tried this but i believe we have to do field mapping,setting the direction(source and target) etc.I have tried the setup in LeanIX as you mentioned and tried creating a factsheet from postman but i am getting a 405 method not found error. So i am trying to follow this document
https://docs-eam.leanix.net/docs/setup-in-servicenow#create-an-integration-user but the thing is,according to the document we need to use a plugin for servicenow which i cant be able to do it in my personal instance.May i know if there is any alternative to plugin installation so that i can implement it in my PDI?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 08:17 AM
Hello @Yashsvi
Thanks for the response,
If i try the above setup mentioned,may i know where can i do field mappping,setting up the direction(source and target) etc? and i have tried the same setup you mentioned in leanIX and tried to create a factsheet from Postman but i am getting a 405 method not found error in response.So i am trying to follow this document https://docs-eam.leanix.net/docs/setup-in-servicenow#create-an-integration-user but the thing is there is a plugin installation in the servicenow setup which i cant be able to do it in my PDI so may i know if there is any alternative to plugin installation that i can implement in my PDI?