Issue with Upload API of item

My usecase is im converting text or base64 data to buffer and calling an API.
This is my request.

var request = require('request');
var fs = require('fs');

const fileContent = 'TG9yZW0gSXBzdW0g'
const bufferData = Buffer.from(fileContent)

const options = {
  url: 'https://api.monday.com/v2/file',
  method: 'POST',
  headers: {
    Authorization: 'Bearer xxxxxxxxxxxxxxxxx',
    'content-type': 'multipart/form-data; boundary=--------------------------141569061256517125556846'
  },
  formData: {
    variables: '{"updateId":1460991786}',
    query: 'mutation add_file($file: File!, $updateId: Int!) {add_file_to_update(update_id: $updateId, file: $file) {id}}',
    map: '{"image":"variables.file"}',
    fileData: { value: bufferData, options: {
      'filename': 'file1.txt',
      'contentType': null
    } }
  }
}

request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Im getting this error. {"errors":[{"message":"Variable file of type File! was provided invalid value","locations":[{"line":1,"column":19}],"value":null,"problems":[{"path":[],"explanation":"Expected value to not be null"}]}],"account_id":11771408}.

Not sure what is wrong. Could someone help me here.

@team, could someone help us on this issue?

Hello @Yash!

It seems that at some point in your code, maybe outside of what was shared in this post, the value being passed as a file is null. Please verify that the file being passed is not null before passing this value in the mutation.

I’d like to also show you some example code of uploading files with variables, for your comparison: file-upload-fetch/uploader.js at main · AlexSavchuk-hash/file-upload-fetch · GitHub