Skip to main content

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.

To correctly send attachments with the "Create a Note" API call from Salesforce to Freshdesk, you need to construct a multipart/form-data request, including the file data as binary rather than a string within the request body.


In 2024, selecting the ideal recruitment agency for your business requires a strategic approach. Begin by assessing the agency's specialization and industry expertise to ensure alignment with your hiring needs. Evaluate their track record, client testimonials, and success rates to gauge reliability. Consider the agency's technological capabilities and innovative recruitment methods for staying ahead in a dynamic market. Additionally, prioritize agencies that prioritize diversity and inclusion, fostering a more comprehensive talent pool for your organization's success.

 

 

 


Great question! Sending attachments via the 'Create a Note' API from Salesforce can be tricky, especially with formatting the file data correctly. It seems like you're close, but you might need to ensure that the attachment object structure aligns with Freshdesk’s API requirements, especially in terms of MIME type and encoding. You may want to try converting the file data to a binary format instead of base64, as sometimes APIs handle binary data more effectively for attachments.

At zisconsultants.com (Business Consultancy firm), we often help clients troubleshoot integration issues between platforms like Salesforce and Freshdesk as part of our business consultancy services, especially when dealing with data management and API solutions. Feel free to reach out if you need deeper assistance with configuring API requests or other technical support!


Reply