I have to Generate a PDF and save it in Blob storage. I mentioned the below code to generate a PDF and send the form data details in CRMAPI.
const generatePDFAndDownload = async () => {
const blob = await pdf((<QuotationPDF formData={formData} />)).toBlob();
const pdfName = `M365_${formData.userCompany.replace(/s/g, '_')}_Quotation.pdf`;
await saveAs(blob, pdfName);
const data = {
name: formData.userName,
email: formData.userEmail,
company: formData.userCompany,
location: formData.userLocation,
service: formData.userService?.map(service => service.title).join(', '),
description: 'Quotation',
};
await CRMAPI(data);
};
And this data sending in CRMAPI this API code is below.
export const CRMAPI = (data) => {
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json;odata=verbose");
myHeaders.append("Authorization", "Bearer 4352345342");
let raw = {
"Title": data.name ? data.name : "",
"Email": data.email ? data.email : "",
"Company": data.company ? data.company : "",
"ContactNumber": data.mobile ? data.mobile : "",
"Country": data.location ? data.location : "",
"OfferSource": data.service ? data.service : "",
"LeadSource": 8,
"Requirements": data.description ? data.description : ""
}
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: JSON.stringify(raw),
};
fetch("https://api.domain.domain.in/api/DynamicsCRM", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
}
So I want this downloaded PDF send in Dynamics 365 CRM list.
I want upload dynamic downloaded PDF in Dynamics 365 CRM.