Upload attachments on Jira through the REST API

Rodrigo Kondo Fernandes February 11, 2022

Hi folks!

Is there a way to upload attachments on Jira through the REST API informing the content of the file as Base64 or binary, or any other way that is not the path of the file itself?

 

Regards,
Rodrigo Kondo Fernandes

5 answers

1 vote
Syed Majid Hassan -Exalate-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 13, 2022

Hi @Rodrigo Kondo Fernandes

This is Syed - a pre-sales engineer @ Exalate

Have you considered an out-of-the-box integration solution for achieving a bi-directional sync between ServiceNow and Jira? Exalate takes the pain out of the DIY approach and provides you extensive ongoing support as well with a dedicated development team ensuring that all latest updates are compatible and do not, possibly, break the integration. 

Please feel free to review Exalate to see if it fits your needs or simply book a demo with us to explore your use case further.

Thanks

Syed

0 votes
Diana_Architect_ZigiWave
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 11, 2022

Hi, @Rodrigo Kondo Fernandes 

My name is Diana and I am a solutions architect at ZigiWave. You can easily connect Jira and ServiceNow. Our no-code integration platform ZigOps will help you achieve that in a matter of minutes. It allows the transfer of default and custom fields between the systems and syncs them in real-time. You can also upload the attachments you want. Our tools reads the schema dynamically and can transfer any fields.

If you want to see how it works in action: book a technical demo.

0 votes
Katarzyna Szumilas_Deviniti_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 14, 2022

Hi @Rodrigo Kondo Fernandes

If you aim to integrate Jira and ServiceNow platforms it can be achieved using Marketplace 3rd party apps. They usually allow you not only to synchronize attachments of different types but also automatically create related issues in the other instance, and keep them in sync also when the data (like field values, statuses, or comments) change. These connections are unidirectional or bidirectional, meaning that all the work made in one platform, could be immediately visible on the second one.

As I'm part of the Issue Sync for ServiceNow team, if you have any questions about this product, I will be happy to assist.

Kind regards,
Kasia

0 votes
Matthias Gaiser _K15t_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 13, 2022

Hey @Rodrigo Kondo Fernandes

I guess, you've seen the REST API docs for uploading attachments, right? You can also check the cloud docs for multiple examples in various programming languages. They're all based on files since that's basically what Attachments are. But there are various ways how you could add the file contents, e.g. in Java you'd need to add a stream which wouldn't need to be based on a file.

Otherwise, the app @Radek Dostál suggested, should work for fine.

Cheers,
Matthias

PS: If you still encounter problems, you can also ask more dev-related questions in the Developer community: https://community.developer.atlassian.com/

0 votes
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 11, 2022

As far as I know Jira doesn't work with base64 file content (this and a few other search hits: https://jira.atlassian.com/browse/JRASERVER-60930)

 

Not sure about raw binary but it sounds.. extremely painful if you don't want to work with any files (how do you get the binary text if not from a file). I imagine there should be a way to do it  since the upload itself must work in some way for all attachment types anyway, but I don't know how to do it myself other than that it sounds like an absolute pain to do. Doing some curl -v -D- stuff with sample .png file for example shows a promising approach, but I don't know how to replicate the curl behaviour without spending a lot more time on this with more searches, and that also depends on which framework/language/library you're working with anyhow. I'm not that familiar with the details what goes into it.

Are you trying to do this from some intermediate point in between the user and Jira? Why else would file not be an option, it's the least complicated and least painful way to do it.

Rodrigo Kondo Fernandes February 11, 2022

Hi @Radek Dostál !

It is being developed an integration between Jira <-> Service Now and the development is stuck on the sending attachments from Service Now to Jira.

I'm still not sure how the integration from Service Now to Jira is being made, but they are saying that they can't send the file, only the base64 content.

Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 11, 2022

Well, in that case I'm afraid that's where my comfort zone ends. If Jira can't accept base64 format it'd have to be converted to binary as an intermediate step I think. This seems like a similar requirement with a solution https://community.atlassian.com/t5/Jira-questions/Jira-dosen-t-decode-base64-attachment-request-REST-API/qaq-p/916427

And from that seems like a free addon could be used to upload base64 attachments: https://marketplace.atlassian.com/apps/1221585/base64-attachment-upload-rest-api?hosting=datacenter&tab=overview

Suggest an answer

Log in or Sign up to answer