Hello,
I apologize if the topic is not in the right place, the problem is urgent and I'm looking for as much help as possible.
I am currently working on a project using Power Pages where I need to upload files to a Microsoft Dataverse record. The process involves creating a new Dataverse record and then uploading a file to a file column within that record using JavaScript (with the Web API).
Here's a snippet of the code that handles the file upload:
// ... (rest of the code)
const reader = new FileReader();
reader.onload = function (e) {
const bodyContents = e.target.result;
const buffer = new Uint8Array(bodyContents);
// Wrap the safeAjax call in a new promise
let innerPromise = new Promise((innerResolve, innerReject) => {
webapi.safeAjax({
type: "PUT",
url: "/_api/cg_commandes(" + newRecordId + ")/cg_fichierstl?x-ms-file-name=" + USER.userCompanyCondensed + "-" + fileName,
contentType: "application/octet-stream",
processData: false,
data: buffer,
success: function (res, status, xhr) {
console.log("File attached");
innerResolve(); // Resolving the inner promise
},
error: function (xhr, status, error) {
console.error("error: " + error);
innerReject(error); // Rejecting the inner promise
}
});
});
innerPromise.then(() => {
resolve(handlePromiseResult(null, 100 / promises.length)); // Resolve the external promise and update progress for this file
}).catch((error) => {
reject(error);
});
};
reader.readAsArrayBuffer(file);
// ... (rest of the code)
The file upload fails since Saturday in dev and production environments (it is extremely problematical !!), not in qualification, and I'm unable to determine the cause. The error handling within the webapi.safeAjax call logs the error, but I haven't been able to resolve the issue from the error messages I'm receiving.
Here is the error :
{
"error": {
"code": "9004010D",
"message": "Common Data Service error occurred.",
"cdscode": "0x80040217",
"innererror": {
"code": "0x80040217",
"message": "No file attachment found for attribute: cg_fichierstl EntityId: 7ecabfd7-7266-ee11-9ae7-000d3a95b11f."
}
}
}
I'm looking for any advice or suggestions on how to resolve this file upload issue. Has anyone encountered a similar problem, or does anyone have insights on how I might troubleshoot or fix this issue?
Thank you in advance for your assistance!