Attachment code is not working in SharePoint server edition which is working fine in SharePoint 2016 On-Premise. find the below Vue.js code for same.
we are migrating this code from SharePoint 2016 to SharePoint server edition in which all other functionalities works and only attachment is not working
Error Message: 500 (Internal Server Error)
var ListRepo = new ListName();
vm.ListObj.AttachmentFiles.results.forEach(function (attachment) {
if (!attachment.isUploaded) {
alert(attachment);
promises.push(ListRepo.addAttachment(vm.ListObj.Id, attachment.data, attachment.FileName).then(function (file) {
//nothing to do here
}, function (err) {
console.error(err);
throw err;
}));
}
});
Promise.all(promises).then(function (result) {
if (moveToNextPhase) {
window.location.href = url;
} else {
if (vm.ReferencesValueP || vm.HistoryRedirect) {
window.location.href = window.location.toString();
}
$.unblockUI();
}
}, function (err) {
//if it's a timeout, chances are the calls are going to succeed...
if (err.statusText === "timeout") {
if (moveToNextPhase) {
window.location.href = url;
}
else {
vm.message = " Error saving . Please contact your administrator Submit.";
alert(vm.message);
setTimeout(function () { window.location.href = window.location.toString(); }, 5000).then(function () {
}, function (err) {
vm.message = "Error saving . Please contact your administrator.";
$.unblockUI();
});
}
}
else {
vm.message =err.statusText;
vm.message = Error saving . Please contact your administrator.";
alert(vm.message);
setTimeout(function () { window.location.href = window.location.toString(); }, 5000).then(function () {
}, function (err) {
vm.message = "Error saving . Please contact your administrator.";
$.unblockUI();
});
//alert(vm.message);
}
});