415 error when trying to send attachment to JIRA form ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2023 08:53 PM
Hi,
I am trying to send attachment from ServiceNow to JIRA through REST message, but I am getting 415 error, tried the same via postman as well and same error.
Attaching screenshot of the configuration that I have done for easier understanding. I have also added the code to build JSON object, although I can see all the details coming in properly in the LOG request that I am capturing.
Please help with this issue. Thanks.
// Code for getting attachment data and building JSON object to send to JIRA
var returnData = {};
var incGr = new GlideRecord('incident');
incGr.addActiveQuery();
incGr.addQuery('sys_id',attachment.table_sys_id);
incGr.addNotNullQuery('correlation_id');
incGr.query();
if(incGr.next()){
var r = new sn_ws.RESTMessageV2('Create Issue', 'Attachment');
var issueID = incGr.getDisplayValue('correlation_id');
r.setStringParameter('issueId',issueID);
var body = {
'attachment': [{
'file': "" + attachment.file_name,
'content_type': "" + attachment.content_type,
'content': "" + GlideStringUtil.base64Encode((new GlideSysAttachment()).getBytes(attachment))
}]
};
r.setRequestBody(JSON.stringify(body));
gs.log('## Log Request ## ' + JSON.stringify(body), 'JIRA-Attachment');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log('## Log Response ## ' + responseBody + ' ' + httpStatus, 'JIRA-Attachment');
//gs.log('## Log Status ## ' + httpStatus );
returnData.status = httpStatus;
returnData.response = responseBody;
return returnData;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2023 08:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2023 09:50 PM
Hi @Danish Bhairag2 , Thanks for reply, I tried the solution from the above post, but I am still getting 415 error. Please check the request body
## Log Request ## {"attachment":[{
"content_type":"image/png",
"file_name":"postman.png",
"size_bytes":"1124594",
"sys_id":"afcbf3e1474ab5104b5b9e79e16d4398",
"Content-Transfer-Encoding":"iVBORw0KGgoAAAANSUhEUgAACGgAAAX0CAYAAACfQ617AAAMP2lDQ1BJQ0MgUHJvZmlsZQAASImVVwdYU8kWnluSkEBCCV1K6E0QqQGkhNACSO82QhIglBgDQcWOL"
}]
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2023 10:29 PM
@Ankur Bawiskar Can you check as you have already provided solution related to this problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 01:01 AM
Since you mentioned the same error came from postman it means the way how request is sent along with body is not proper
Did you check JIRA documentation?
are you not using JIRA spoke for this?
check this link
How to send attachments from servicenow to jira
check this KB as well
Jira spoke - upload attachment from Jira to Service now
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