The CreatorCon Call for Content is officially open! Get started here.

REST API attachments Transfer to JIRA

harishdasari
Tera Guru

Hi,

We have already implemented Snow-JIRA integration and built it by our own not using the John anderson POC for snow-jira integration update set.

Requirement is we want to implement the attachment transfer from Snow to JIRA application using REST API.

I have referred lot of community articles but unable to implement it because JIRA application supports only Multipart/form-data, it will not support Binary data format for attachments.

Anyone if worked please help me with code, how they have implemented would be really helpful for lot developers.

Thank you.

20 REPLIES 20

harishdasari
Tera Guru

find_real_file.png

harishdasari
Tera Guru

Hi Ankur,

without using midserver Jira cannot consume the webservice call because JIRA is onprimse application and firewall will block servicenow webservice call.
connection cannot be established without using the midserver.

please let meknow how can I mive forward. I found lot of article about sending attachment using attachment API and none of the article is helpful.
there is no proper direction how to use the ATTACHMENT API for multipart/form-data. lot of community article just reposted the same old articles where there is no proper info about sending attachment to Jira.

thank you.

Hi Harish,

 

Were you able to achieve this requirement ?

 

Thank you

Hi NamrataJain,

No we were not able to send the attachments to Jira.

Thanks

 

 

Swapnil Soni1
Giga Guru

Hi,

In a perfect world, you should be able to use this,

 

RESTMessageV2 - setRequestBodyFromAttachment(String attachmentSysId) 

 

Write your script and done. 

 

  var request = new sn_ws.RESTMessageV2();

 

              request.setHttpMethod('post');

 

              request.setRequestHeader("X-Atlassian-Token","no-check");

 

                request.setRequestHeader("Content-type","multipart/form-data");

 

              request.setEndpoint('https://{jiraURL}/rest/api/2/issue/SN-2/attachments');

 

              request.setBasicAuth("username","password");

 

              request.setRequestBodyFromAttachment('abd7460b0fe39e001dc906ace1050e9f'); //sys_id of attachment record

 

            var response = request.execute();

 

 

 

But I have not been able to get this to work OOB. I believe Jira is only expecting a multipart-form/data message and ServiceNow is sending an application/octet-stream (i think).   The only way I have been able to send attachments via REST is with the Mid server using a custom .jar file called from a script include.

 

Mark correct or helpful if this helps.

Thanks

Swapnil