Unable to add attachments to a service ticket through JIRA Rest API using Node Js request


I was able to add attachment using Postman but when trying to do the same through JIRA Rest API using Node Js request, it does not seem to be working.

I get a status code of 200 but its gives me an empty response and upon checking the JIRA ticket, I couldn’t find the attachment.

Below is a code I am using

var upload = multer({ dest: './jiraAttachments' })
router.post('/uploadAttachments', upload.any(), function (req, response) {
    let fieldNames = JSON.parse(process.env.advisoryDetails)

    var formData = new FormData();
    for(let i=0; i<req.files.length; i++){
        formData.append('file', fs.createReadStream(req.files[i].path))
    let formHeaders = formData.getHeaders();

    var options = {
        url: fieldNames.apiEndpointUrl + req.body.key + '/attachments',
        headers: {
            'X-Atlassian-Token': 'no-check',
        auth: {
            user: fieldNames.userId,
            password: fieldNames.password
        data: formData,
        processData: false,
        contentType: false

    request.post(options, function (err, res, body) {
        if (err) {
            err['statusCode'] = res.statusCode
        } else {
            console.log('status code', res.statusCode)
            body['statusCode'] = 200

Here is a screenshot of the console. As you can see I have the file and also the correct headers. It does give me a status code of 200 but as said earlier, the response is empty and there is no attachment added to the ticket.

I have posted the same question in Atlassian community and It’s been like 50 days now and still no response.

I have tried multiple approaches but nothing is working. Any help is appreciated. Thanks!