Attachment code is not working in SharePoint server edition

Charudath Nandan 0 Reputation points
2023-08-07T08:48:11.3266667+00:00

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);

 

 

                    }
                });
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,230 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ChengFeng - MSFT 5,045 Reputation points Microsoft External Staff
    2023-08-08T08:51:32.9166667+00:00

    Hi @Charudath Nandan,

    Sorry, can't reproduce your situation at the moment, can you provide a more detailed scenario?

    Could you please tell me how you got it working in SharePoint 2016 On-Premise?

    Could you please tell me how you use above code in SharePoint server edition?


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards

    Cheng Feng

    0 comments No comments

  2. Charudath Nandan 0 Reputation points
    2023-08-09T08:51:38.33+00:00

    Hi @ChengFeng - MSFT

    The above piece of code added in the CSOM webpart, where we are trying to upload a document from local system to SharePoint list, which is developed through vuejs of 2.5.16 version. the same code is working fine in 2016 on-premise server. now after migrating the same to SharePoint server edition it is not working.

    The document is getting attached to form/list without any issue. but after on custom button click (save) we are getting the error as 500 (Internal Server Error)

    Thanks in advance,

    Charu

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.