Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add an attachment to an issue using OAuth not basic auth?

Sajan Sharma
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 16, 2020

I'm trying uploading an attachment to an issue using OAuth, but it's throwing error. can anybody help to show how it works? what headers it requires and how it accepts the files.

 

Everything else is working fine, only attachment is not working.

1 answer

1 accepted

1 vote
Answer accepted
Ankit
Atlassian Partner
June 16, 2020

Hi Sajan,

You can follow the guide provided by Atlassian here: https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-oauth-authentication/

However, to use OAuth, you'll need to create a java client while using this guide.

Thanks,

Ankit

Sajan Sharma
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 16, 2020

Thanks, Ankit I have configured everything required for communication. I'm able to create issues successfully, only the attachment part which is left. 

I need to know how the Jira system accepts the attachments? what params are required?

Ankit
Atlassian Partner
June 16, 2020

Adding an attachment has a different endpoint. /rest/api/3/issue/<Issue-Key>/attachments

It has to be sent as a Multipart form data. If you're using curl, you can send the local file as attachment using -F option and it must be a file.

curl -F "file=@localfile.txt" https://your-domain.atlassian.net/rest/api/3/issue/<Issue-Key>/attachments

If you're using the Java Client Library, you can use MultipartEntityBuilder to do the same.

You can find more info here: https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-issue-issueIdOrKey-attachments-post 

However, I'll recommend testing this endpoint on Postman first. You can test it out with basic authentication/API key when using postman since you're only trying to test attachments. You'll find step by step instructions here: https://medium.com/@vdespa/automatically-testing-file-uploads-multipart-form-data-with-postman-and-gitlab-ci-ebfa371992b1

 

Thanks,

Ankit

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events