I'm getting an error with the following code. Error: "Unable to upload attachments to server, issue has not been created.". Nothing in the error message helps troubleshoot the issue.
byte[] file = File.ReadAllBytes($@"{MyImageLocation}"); // Local path to .jpg
Issue issue = _jiraClient.CreateIssue("AB");
issue.Summary = "Hello World"
issue.Priority = "Medium"
issue.Description = "Testing attachments"
issue.AddAttachment("MyImage.jpg", file);
issue.Type = "Bug";
await issue.SaveChangesAsync();
My Jira client connection is working. I can create work items without attachments. I can attach to work items manually through the Jira web interface. The image is small.
Hi Alex,
From looking over the JIRA REST API reference on the api/2/issue endpoint, I don't see any clear schema notes that indicate we can add attachments at this point.
From looking at some other threads on this topic in https://community.atlassian.com/t5/Questions/Create-Issue-with-attachment/qaq-p/280748 and https://community.atlassian.com/t5/Answers-Developer-Questions/Create-Issue-with-Attachment-using-REST-API/qaq-p/509160
It appears that the REST endpoint used to create issues does not have a means to add attachments. Instead the suggestion appears to be to create the issue first, get the issuekey from that issue, and the make a second rest call to the api/2/issue/{issueIdOrKey}/attachments endpoint.
So I don't believe the problem is specific to using C#, but rather this appears to be a limitation of how Jira can add attachments.
Thanks! Per your suggestion, I tried attaching the image after saving and then saving again. For the second save, I don't need to 'await' so there's minimal downside to needing a second submission.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.