We are calling “create a Note” API of fresdesk from Salesforce but not able to send attachments in the correct format. Can anyone please help with an example of how to send attachments with the request ?
Our code:
LWC
onFileUpload(event) {
console.log('event.target :: ', event.target);
console.log('event.target.files, ', event.target.files);
const file = event.target.filesv0];
console.log('file:: , ', file);
var reader = new FileReader()
reader.onload = () => {
console.log('reader.result :: ', reader.result);
// var base64 = reader.result.split(',') 1]
// this.fileData = {
// 'filename': file.name,
// 'base64': base64
// }
this.fileData.name = file.name;
this.fileData.base64 = reader.result.split(',') 1];
this.fileData.file_size = file.size;
this.fileData.content_type = file.type;
}
reader.readAsDataURL(file);
console.log('filedata', this.fileData);
console.log('filedata', lthis.fileData]);
this.newNoteFormData.attachments = } Sample req body: { “body”:”Sample body”, private:true, attachments>] : this.fileData] } we are sending FileData as a string in the request body.