I’m trying to use the POST /rest/api/2/issue/{issueIdOrKey}/attachments to add an attachment to an issue I just created using POST /rest/api/2/issue/. The issue is created fine, but when I try to post an attachment I get the error ‘Header section has more than 10240 bytes’. This is the code I use to send the attachment:
function uploadAttachments(supportFormData, callback) {
const url =
'https://somewhere.com/jira/rest/api/2/issue/' +
supportFormData.issueId +
'/attachments';
var options = {
url: url,
headers: {
Authorization: { user: username, password: password },
'X-Atlassian-Token': 'nocheck'
}
};
var r = request.post(options, function(err, res, body) {
if (err) {
console.error(err);
callback(false);
} else {
console.log('Upload successful! Server responded with:', body);
callback(false);
}
});
var form = r.form();
form.append('file', supportFormData.attachments[0].contents, {
filename: supportFormData.attachments[0].fileName,
contentType: supportFormData.attachments[0].contents
});
}
supportFormData.attachments[0].contents is of type ‘buffer’.
And this is the response I get:
org.apache.commons.fileupload.FileUploadException: Header section has more than 10240 bytes (maybe it is not properly terminated)