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-23-2023 01:19 AM
Hi @Ankur Bawiskar,
We are not flow designer and JIRA spoke for integration, we are using REST messages for sending the payload, attaching sample payload that I am sending Request as.
## 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-23-2023 01:27 AM
check this link
Sending attachment from ServiceNow to Jira using BR and REST message
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 01:45 AM
@Ankur Bawiskar Yes, checked this and modified the payload information to be sent according to your code from above post, which you can see above in my previous reply, but still I am getting same 415 error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 02:58 AM
error 415 means unsupported format
what did you set in content-type in the REST message?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 03:22 AM