In one of my tasks,i was struck with one issue,that is "While uploading multiple files into document library with REST API".

Iam trying to upload multiple files in library with REST calls for an APP development,my issue is if i wants to upload 4 to 5 documents at once its storing only 3 documents and further giving "Conflict" error".below is the attached screenshot of exact error.

Error within screenshot are : status Code : 409 statusText :conflict I have searched many blogs but i didnt find any solution,can anyone please help me on this issue.

For this operation iam uploading different files as an attachment to an list item,below is the code used for uploading multiple files.

function PerformUpload(listName, fileName, listItem, fileData)
    var urlOfAttachment="";
    var itemId = listItem.get_id();

    urlOfAttachment = appWebUrl + "/_api/web/lists/GetByTitle('" + listName + "')/items(" + itemId + ")/AttachmentFiles/add(FileName='" + fileName + "')"
    // use the request executor (cross domain library) to perform the upload
    var reqExecutor = new SP.RequestExecutor(appWebUrl);
        url: urlOfAttachment,
        method: "POST",
        headers: {
            "Accept": "application/json; odata=verbose",
            "X-RequestDigest": digest              
        contentType: "application/json;odata=verbose",
        binaryStringRequestBody: true,
        body: fileData,
        success: function (x, y, z) {
        error: function (x, y, z) {

           // alert("Oooooops... it looks like something went wrong uploading your file.");


Thanks in advance, Naresh

enter image description here

EDIT: Same issue while trying to create a list item and then add attachments to it using custom form and ECMA script. Below is the error message body:

error Conflict undefined -2130575305, Microsoft.SharePoint.SPExceptionSave Conflict. Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes.

Interesting thing is this error occurs only when the file is in MBs. If the file size is less then it will work properly.

  • I am also stuck with the same problem.My code is also similar to yours. Error while uploading files more than 1 mb size.Did you get a solution for this?
    – Unnie
    Mar 10, 2014 at 8:48

3 Answers 3


The issue is that your POSTing another attachment before SharePoint is done processing the item with larger files. So when you try to perform another operation on the item (adding another attachment, etc) a race condition is is reached and SharePoint throws the error. When the attachment files are smaller, the process has time to complete before you start the next upload.

You need to find a way to check if the item has completed it's processing. One way of doing this might be to do a get and check the item's etag and ensure that it has incremented the correct number of times before sending another POST.

  • i have called the method to upload the 2nd file on the success event of the 1st file upload..but still i get this error.
    – Unnie
    Apr 1, 2014 at 17:45
  • I understand. But SharePoint has not completed processing the changes to the SPListItem. And it's the SPListItem that is causing the race condition. Add some debug statements or use console.log to see the etag on the list item itself. This could also have soemthing to do with event receivers or WFs running on the item. But I promise you this is what is causing the issue. I've experienced it myself. Apr 1, 2014 at 17:51

You have to change the code a little bit. The async operations are causing these problems. Have to change it to sync using ajax & its async: false property


The 409 conflicts occur when the SP REST API attempts to make edits to a list item while another edit is processing. The SPRequestExecutor is a client side wrapper for the AJAX calls to the REST API endpoints and can be considered equivalent to any other XHR async request. Developers can make async requests that execute synchronously by adding a function wrapper to the RequestExecutor.executeAsync method as seen [here].1 Each call is "then-able" and can be chained such that each call executes only when the previous has completed.


var attachmentArray = [{fileName,fileData}];
var attachmentUpload = function(index,attachmentArray) {
    return reqExecutor.executeQuery(attachmentArray[index]).then(
        function(res) {
            return attachmentUpload(index,attachmentArray)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.