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.