Get uploaded document id using JQuery

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


  • Edited by Asif Kazi 16 hours 35 minutes ago
August 28th, 2015 11:04am

I can't see the issue in your code, but there's a working example to compare against here;

http://sharepoint.stackexchange.com/questions/96493/get-id-of-current-inserted-item-by-javascript

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 11:21am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics