Send message error 'file must be required'

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?

Hey @nddm,

Welcome to the Sendbird Community. Let me take a look into this and see if I can recreate it.

Hey, thank you.

Let me know if you need any more information.

Ran into the same issue, solved by adding a filename to the FormData append:

form.append('file', file, "filename.jpg");