Hello,
I keep getting the following error data when I try to send a message to a group_channel with the platform API. I’m using Node and axios.
data: {
message: "\"file\" must be required.",
code: 400105,
error: true,
},
}
I use the following code:
let url = `${BASE_URL}/v3/group_channels/${channel_url}/messages`;
const form = new FormData();
const boundaryString = form.getBoundary();
let binaryHeaders = {};
let binaryContentType = `Content-Type`;
binaryHeaders[binaryContentType] = `multipart/form-data; boundary=${boundaryString}`;
let binaryHeaderApiToken = `Api-Token`;
binaryHeaders[binaryHeaderApiToken] = `${TOKEN}`;
form.append('message_type', "FILE");
form.append('user_id', userId);
form.append('file', file);
let response = await axios.post(url, form, {
headers: binaryHeaders
});
It’s the same code I use to upload the user’s profile_image yet here it always says the file must be required. I’ve tried passing a buffer, local file location, stream and it returns the same error all the time even though I’m passing the file in the form.
Can you help me please?