Hey folks,
Stuck on a weird edge case with the Genesys Cloud Web Messaging SDK (v1.2.4). We’re trying to let customers upload PDF contracts and image receipts, but the sendFile method is throwing a 400 Bad Request error for seemingly valid files.
Here’s the setup. I’m initializing the guest session normally, then calling:
await guest.sendFile({
file: fileObj,
name: 'contract.pdf',
mimeType: 'application/pdf'
});
The fileObj is a standard File object from an <input type="file"> element. I’ve verified the fileObj.type is application/pdf and the size is well under the 5MB limit (it’s about 200KB). Yet the API responds with:
{
"code": 400,
"message": "Invalid file type or size",
"status": "Bad Request"
}
It’s not just PDFs. JPEGs are also getting rejected with the same message. PNGs work fine. This feels like a MIME type mapping issue on the server side, but the docs list application/pdf and image/jpeg as supported.
I tried manually overriding the mimeType in the payload to image/jpeg for a JPEG file, but that didn’t help. The error persists. Is there a hidden whitelist of MIME types that’s different from the public docs? Or am I missing a step in how the SDK packages the file before sending?
Also, the SDK doesn’t give any client-side validation errors before sending, which makes debugging this a pain. I have to wait for the network request to fail. Any ideas on how to pre-validate the file type before calling sendFile?
Thanks.