Nodejs - Header section has more than 10240 bytes

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 =
      '' +
      supportFormData.issueId +

    var options = {
      url: url,
      headers: {
        Authorization: { user: username, password: password },
        'X-Atlassian-Token': 'nocheck'

    var r =, function(err, res, body) {
      if (err) {
      } else {
        console.log('Upload successful!  Server responded with:', body);

    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)