Hi @kk281 ,
It's likely that the issue is related to the format of the base64 data when posting it to the SharePoint List. Ensure that the base64 string is correctly formatted and that the appropriate headers are included in the REST POST call. Specifically, check that the 'Content-Type' header is set to 'application/json;odata=verbose'.
This is sample code which you can use -
var url = "www.yourdomainname.com/_api/web/lists/getbytitle('<List Name>')/items";
var item = {
"__metadata": { "type": "<ListItemEntityTypeFullName>" },
"Title": "Test File",
"File": {
"__metadata": { "type": "SP.FieldUrlValue" },
"Description": "Test File",
"Url": "data:application/octet-stream;base64," + base64Data
}
};
$.ajax({
url: url,
type: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(item),
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
console.log("File uploaded successfully");
},
error: function (error) {
console.log(JSON.stringify(error));
}
});