Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Add an attachment to existing Issue

As I got to know we cannot add an attachment at the time of creating issue. So I am trying to add an attachment to existing Issue.

The below code I have got from the already attached attachment of existing Issue. Do I need to give all the parameters below for POST?

My rest api code looks like this below:


"attachment" :
"0" :
"self" :
"id" :
"filename" :
"Capture error.JPG",
"author" :
"self" :
"accountId" :
"emailAddress" :
"avatarUrls" :
"48x48" :
"24x24" :
"16x16" :
"32x32" :
"displayName" :
"Bindiya Vikram Naik",
"active" :
"timeZone" :
"accountType" :
"created" :
"size" :
"mimeType" :
"content" :
"thumbnail" :

1 answer

0 votes
Warren Community Leader May 17, 2021

Hi @Bindiya Vikram Naik 

No you definitely don't need all those.

I implemented the code as per the answer by Jeff Caron in and it works perfectly

sorry I could not understand.

What parameters I need to share when doing it thru REST api, What should I send  payload? not clear with that. or rather how do I send the file to be uploaded in payload.

I also get below error:

An unexpected error has occurred: (SyntaxError) : Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'multipart/form-data' is not a valid HTTP header field name.

Warren Community Leader May 17, 2021

Hi @Bindiya Vikram Naik 

Below is my C# code (in it's simplest form, with no error checking) that I use to add an attachment to an existing issue.

It is called by passing in the issue key and the FileInfo version of the file

   AddAttachment("ABC-1234", fname);


public static void AddAttachment(string key, FileInfo Attachment)
HttpWebRequest request = null;

string fullURL = @"/rest/api/3/issue/" + key + "/attachments";

var boundary = string.Format("----------{0:N}", Guid.NewGuid());
var content = new MemoryStream();
var writer = new StreamWriter(content);

var fs = new FileStream(Attachment.FullName, FileMode.Open, FileAccess.Read);
var data = new byte[fs.Length];
fs.Read(data, 0, data.Length);

writer.WriteLine("--{0}", boundary);
writer.WriteLine("Content-Disposition: form-data; name=\"file\"; filename=\"{0}\"", Attachment.Name);
writer.WriteLine("Content-Type: application/octet-stream");

content.Write(data, 0, data.Length);


writer.WriteLine("--" + boundary + "--");
content.Seek(0, SeekOrigin.Begin);

request = WebRequest.Create(fullURL) as HttpWebRequest;
request.Method = "POST";
request.ContentType = string.Format("multipart/form-data; boundary={0}", boundary);
request.Accept = "application/json";
request.Headers.Add("Authorization", "Basic " + GetEncodedCredentials());
request.Headers.Add("X-Atlassian-Token", "nocheck");
request.ContentLength = content.Length;

using (Stream requestStream = request.GetRequestStream())


If this (or what you're using) doesn't work for you, you'll need to show some code and details here so someone can try to understand what's going wrong for you. 

Hello @Warren @Ravi Sagar 

I am trying it on Talent APItester extension in chrome. Kindly find the attachment for more clear picture.


Problem statement: Now I get 200 Response code but still attachment is not getting uploaded in respective issue. Please help.




Warren Community Leader May 17, 2021

Hi @Bindiya Vikram Naik 

Ah okay, so this APITester that you're using is a bit like Postman in that you don't write any code? In that case, I can't really help much because I know nothing about APITester or what's going on "under the hood".


Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you