I have tried this code but it is not working....
string url = $"http://jiraurl/rest/api/2/issue/{key}/attachments";
var client = new HttpClient();
var header = new AuthenticationHeaderValue("Basic", Password);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Authorization = header;
client.DefaultRequestHeaders.Add("X-Atlassian-Token", "no-check");
MultipartFormDataContent multiPartContent = new MultipartFormDataContent("-data-");
FileInfo fi = new(@"D:/CSN/Process Project Request.pdf");
ByteArrayContent byteArrayContent;
using (var ms = new MemoryStream())
{
fi.CopyTo("abc");
var fileBytes = ms.ToArray();
//string fileString = Convert.ToBase64String(fileBytes);
byteArrayContent = new ByteArrayContent(fileBytes);
}
multiPartContent.Add(byteArrayContent, "file", fi.FullName);
var response = await client.PostAsync(url, multiPartContent);
var result = response.Content.ReadAsStringAsync().Result;
if (response.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception(result);
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.