Part of my application retrieves base64 encoded audio data from another API, stores that data as a variable in a data buffer, and then uses that data as the "binary" parameter for the create custom user greeting endpoint. This worked perfectly in Nodejs, I was able to convert the base64 encoded audio data into a stream and pass that into the node form-data like so:
const NodeFormData = require('form-data'); formData = new NodeFormData(); let body = { type: "Introductory", answeringRule: {id: "38"} } formData.append('json', new Buffer.from(JSON.stringify(body)), { filename: 'request.json', contentType: 'application/json' }); formData.append('binary', audioStream, { filename: 'audioStream.mp3', contentType: 'audio/mpeg' });
However, when refactoring the application for native browser JavaScript, I get the error:
"Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'."
It appears that the native JavaScript FormData must have a Blob object if you are attaching a file. However, when I change the format of the audio data from stream to Blob, I get this error message on the RingCentral end:
"Invalid Attachment Media Type"
It is important to note that the audio data in my application is never saved into a file, only stored in a variable, so I cannot simply attach a file. How can I get this process to work in native JavaScript?