Question

How to send attachments while calling "Create a Note" API of freshdesk from salesforce

  • 27 December 2023
  • 2 replies
  • 80 views

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.files[0];

        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', [this.fileData]);

 

        this.newNoteFormData.attachments = [this.fileData];

    }

 

Sample req body:

 

{

“body”:”Sample body”,

private:true,

attachments[] : [this.fileData]

}

 

we are sending FileData as a string in the request body.


2 replies

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.

 

 

 

Reply