I have to do integration from ServiceNow to third party application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 01:19 AM
Hi,
I have to do integration from ServiceNow to third party application for my learning purpose.
Can anyone please confirm which third part application I can use for free or can we use postman for this ServiceNow to third party application.
Regards,
Nivedita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 01:25 AM
You cannot use postman for the third party integration. Instead, you can use it for testing of the APIs. I would recommend you to do third party integration with Salesforce using oAuth 2.0 You can have free developer instance from here just like ServiceNow-
https://developer.salesforce.com/
Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 01:45 AM
Hi @Amit Pandey,
Thank you so much. I have created free instance in salesforce using link which you have given.
Can you please help how I can check created request number, request item and task which has been created in ServiceNow instance for integration.
Regards,
Nivedita
Regards,
Nivedita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 07:22 AM
Can you elaborate more on your requirement? You need to setup REST message with endpoints, authentication profile etc. and trigger it with the help of Business Rules. Alternatively, you can pass the endpoints, authentication etc in business rule itself. Sharing an outline of business rule with you.
(function executeRule(current, previous /*null when async*/ ) {
try {
var client_id = 'Enter your client id';
var client_secret = 'Enter your client secret';
var grant_type = 'client_credentials';
var token_endpoint = 'https://*****prodtest.sandbox.my.salesforce.com/services/oauth2/token';
var token_grant_url = token_endpoint + "?grant_type=" + grant_type + "&client_id=" + client_id + "&client_secret=" + client_secret;
var token_request = new sn_ws.RESTMessageV2();
token_request.setEndpoint(token_grant_url);
token_request.setHttpMethod("post");
var token_response = token_request.execute();
var response_body = token_response.getBody();
var response_obj = JSON.parse(response_body);
var access_token = response_obj.access_token;
gs.info('Token request response: ' + response_body);
gs.info('Access token: ' + access_token);
// Use the access token to make API calls
var api_request = new sn_ws.RESTMessageV2();
api_request.setEndpoint('https://*****prodtest.sandbox.lightning.force.com/services/data/v58.0/sobjects/case');
api_request.setHttpMethod('post');
api_request.setRequestHeader('Authorization', 'Bearer ' + access_token);
api_request.setRequestHeader('Accept', 'application/json');
api_request.setRequestHeader('Content-Type', 'application/json');
var restObj = {
"Contact__c": current.contact.name + '',
"ServiceNow_SysID__c": current.sys_id + '',
"Priority__c": current.priority.getDisplayValue() + '',
"Subcategory__c": current.subcategory + '',
"Number__c": current.number + '',
"Assignment_Group__c": current.assignment_group.name + '',
"Assigned_to__c": current.assigned_to.name + '',
"Channel__c": current.contact_type.getDisplayValue() + '',
"Short_Description__c": current.short_description.toString().replace(/\v|\r|\0/g, "") + '',
"Description__c": current.description.toString().replace(/\v|\r|\0/g, "") + ''
};
var restStr = JSON.stringify(restObj);
api_request.setRequestBody(restStr);
gs.info('API Request Endpoint: ' + api_request.getEndpoint());
gs.info('API Request Headers: ' + api_request.getRequestHeaders());
var api_response = api_request.execute();
var api_response_body = api_response.getBody();
var httpStatus = api_request.getStatusCode();
if((httpStatus != 200) && (httpStatus != 201)){
gs.eventQueue("httpStatusFailed", current, current.number, api_response_body);
}
gs.info('API Response Object: ' + api_response);
gs.info('API Response Body: ' + api_response_body);
gs.info(current.number + "\nSalesforce Case Create : HTTP Status : " + api_response.getStatusCode() + "\nRequest Body : " + api_request.getRequestBody() + "\nResponse Body : " + api_response_body);
} catch (error) {
gs.error('An error occurred: ' + error);
}
})(current, previous);
Please mark my answer helpful and correct.
Regards,
Amit Pandey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 07:55 AM
Hi @niveditakumari ,
In the video link provided below you'll find everything you need to know to get started with Integrations in ServiceNow. also there is complete process of integrating ServiceNow with Spotify at the end of video.
Integration Complete ServiceNow | Web Services - YouTube
if you find this helpful, please mark my answer as accepted and helpful.
Regards,
Ubada Barmawar.