JIRA integration: Passing Work notes as Comments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 02:58 AM
Dear Members,
Requirement: - Sending Work notes as Comment via REST API to JIRA.
Implementation: - I have created the below Business rule which runs on Insert/Update of an Incident and also a REST API.
Issue: - Getting the error JIRA Comments: {"errorMessages":["There was an error parsing JSON. Check that your request body is valid."]} in the System Log. However, the Comment in the JIRA gets created when parameters are passed directly from the Outbound REST API Message.
Release: - Xanadu
Please suggest.
Outbound REST API Message: - https://<confidential>.atlassian.net/rest/api/3/issue/${correlation_id}/comment
Thanks,
Neha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 03:37 AM
the issue is with the way how getJournalEntry(1) gives the value and the work notes contain special character which JIRA might not be handling
Do this
1) remove the POST Content field and set the Request body via script
Something like this if it works
var comments = current.comments.getJournalEntry(-1);
var body = '{"body":{"content":[{"content":[{"text":"${work_notes}","type":"text"}],"type":"paragraph"}],"type":"doc","version":1}}';
body = body.replace("${work_notes}", current.comments.getJournalEntry(1).toString());
var finalbody = JSON.stringify(body);
r.setRequestBody(finalbody);
var response = r.execute();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 04:27 AM
I have modified the code with your recommendation as follows but still getting the error in response: -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 04:34 AM
seems issue with your BR and retrieving the value from journal field
BR logs are coming?
Are you updating the comment as admin or non-admin?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 08:41 AM
@Ankur Bawiskar Yes, the issue seems with retrieving the value from Journal field and passing it to the Outbound REST Message.
Yes, BR logs are coming and I am updating the comment as an Admin.
My modified BR but still getting the same error:-
Error: -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 08:50 AM
very difficult to debug without having the actual access to the instance.
Is this happening all the time?
this is for incident table right?
Also it's strange as you are getting the work notes in logs but unable to send although hard-coding the same work notes work in BR
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader