Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

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
status Text :conflict

I have searched many blogs but I didn't 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.

C#
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);
        reqExecutor.executeAsync({
            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) {
                alert("Success!");
            },
            error: function (x, y, z) {
                alert(z);

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


            }
        });
    }



Thanks in advance,
Naresh



http://www.flickr.com/photos/112048958@N06/11461491596/[^]
Posted
Updated 29-Dec-13 18:12pm
v7

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900