Unable to create the ticket in third party application when i create an incident in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 03:14 AM
Hi,
I am facing an issues while creating the ticket in third party application while creating an incident in servicenow.
I have create the rest message to send the data from servicenow to third party application and i have configure the endpoint, hearder and all of the third party application.
I have used the rest message in the business rule to trigger.
when i tried create the ticket from post man it working as expected and create the ticket in third party application perfectly but when i tried to create incident in servicenow and that suppose to create ticket in third party application but it is not creating the ticket and there no correlation id is not generated on incident in servienow.
Could you please tried to help us
it's urgent for us.
Thank you,
Naga
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 03:22 AM
Hi,
Unfortunately you didn't share how you are triggering it and the script involved?
What's the http status? what's the error message?
Did you add gs.info() statements for debugging?
What type of authentication you are using?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 03:58 AM
Hi Ankur,
I have tried with the below code.
HTTP Headers :
Content-Type application/json
authentication : Basic
Business rule triggering conditions:
Before insert
when to run
Priority is low
Correlation id is empty
(function executeRule(current, previous /*null when async*/ ) {
var request = new sn_ws.RESTMessageV2('third party application', 'Create an Incident');
request.setStringParameterNoEscape('short_description', current.short_description);
request.setStringParameterNoEscape('description', current.description);
request.setStringParameterNoEscape('category', current.category);
request.setStringParameterNoEscape('subcategory', current.subcategory);
request.setStringParameterNoEscape('impact', current.impact);
request.setStringParameterNoEscape('urgency', current.urgency);
request.execute();
var response = request.execute();
var requestBody = request.getRequestBody();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log(requestBody);
responseJSON= responseBody.substring(10,responseBody.length-1);
parsedJSON = JSON.parse(responseJSON);
var fsIncidentNumber = parsedJSON['number'];
var fsIncidentsysid= parsedJSON['sys_id'];
var logString = 'FS Incident Number -' +fsIncidentNumber +"\nfs incident Sys ID -"+fsIncidentsysid;
gs.log(logString, 'BR- Create incident in FS');
}) (current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 04:11 AM
What did you get in logs?
What http status did you get in response?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 04:21 AM
Hi Sumanth
In the logs, I could see this.
responseBody{"description":"Validation failed","errors":[{"field":"description","message":"It should be of type String","code":"missing_field"},{"field":"status","message":"It should be one of these values: '2,3,4,5'","code":"missing_field"},{"field":"subject","message":"It should be of type String","code":"missing_field"},{"field":"priority","message":"It should be one of these values: '1,2,3,4'","code":"missing_field"},{"field":"requester_id","message":"One of the following is mandatory: requester_id, phone, email","code":"missing_field"}]}
Could you please try to help me with script.