Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Get uploaded document id using JQuery

$
0
0

I'm trying to retrieving document ID of newly uploaded document using JQuery, any help highly be appreciated.

I'm trying below code which is not working error, 404 not found;

function getListData() {

    var docTitle = jQuery('#fileButton').val();
var fileCollectionEndpoint = String.format(
            "{0}/_api/web/lists/getByTitle('Private%20Documents')/RootFolder/Files/Get(url='{1}', overwrite=true)",
            _spPageContextInfo.webAbsoluteUrl, docTitle);
    
    $.ajax({
        url: fileCollectionEndpoint,
        type: "GET",
        headers: {
            "accept": "application/json;odata=verbose",
            "content-type": "application/json;odata=verbose",
        },
        success: Succeeded,
        error: function Failed() {
        alert('Error!');
    }

    });
}

function Succeeded(data) {

   var listItemInfo = "";

   $.each(data.d.results, function (key, value) {
       listItemInfo += 'ID: ' + value.Id +
           ';';
   });

   alert(listItemInfo);
}



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>