REST: Read all Items from SharePoint Document Library

  1. $.ajax({  
  2.     url: "http://servername:1122/sites/HR/_api/web/lists/getbytitle('Documents')/items?$select=ID,FileRef,FileLeafRef",  
  3.     method: "GET",  
  4.     headers: {  
  5.         "Accept""application/json; odata=verbose"  
  6.     },  
  7.     success: function(data) {  
  8.         $('body').html(JSON.stringify(data));  
  9.         console.log(JSON.stringify(data));  
  10.         $.each(data.d.results, function(index, item) {  
  11.             console.log(item.ID + "," + item.FileRef + ", " + item.FileLeafRef);  
  12.         });  
  13.     },  
  14.     error: function(data) {  
  15.         $('body').html(data);  
  16.         console.log("error");  
  17.     }  
  18. });