I want to fetch Document Library List in my application using java-script/Jquery How can I fetch SharePoint Document Library record and show in my application.

  • Q.1.Do you want each document name in your library or you are fetching one document based on some condition? Q.2. Does your library have folders in it? Feb 20, 2017 at 12:02
  • Q.1. I want each doc name.(List record). Q2. No any folder only doc.
    – Admin
    Feb 20, 2017 at 12:20
  • If you need any help regarding my answer, feel free to ask Feb 20, 2017 at 20:18

1 Answer 1


These are the two easy ways of doing it

  1. Using REST Services
  2. Using JavaScript Object Model

1. Using REST

Using REST services, you can make a REST call to the document library and simply get all the items in an array.

Here the REST call will be: http://*your site*/_api/web/GetFolderByServerRelativeUrl(LibName )/Files

When the call is completed, the results are stored in FilesData array which you can use in your application.

Eg. var name = FilesData.d.results[i].Name would get you the name and var URL = FilesData.d.results[i].ServerRelativeUrl will get you the URL of the document. So if you want the document to be downloadable from your application simply store it in a variable as var DownloadLink = <a href='" + URL + "'>name</a>

Note: You can also get other properties like created, modified, created by, modified by, etc.

    var LibName = "Documents";
    $("#btn").click(function(){  //btn is the id of the button, you can call this function on any event
    function StoreInArray(){
    var CallLibrary = GetListItems();

    $.when(CallLibrary).then(function (FilesData) {
            for (var i = 0; i < FilesData.d.results.length; i++) {
                var name = FilesData.d.results[i].Name;
                var url = FilesData.d.results[i].ServerRelativeUrl;

    function GetListItems() {
        var siteURL = _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('"+LibName+"')/Files";
        return $.ajax({
            url: siteURL,
            async: false,
            method: "GET",
            headers: { "Accept": "application/json;odata=verbose" }

2. Using JavaScript Object Model

See the msdn link How to: Retrieve List Items Using JavaScript

  • Thanks for reply Mayank. But I want to access sharepoint site in my other application not sharepoint how can I access this in my other application.?
    – Admin
    Feb 21, 2017 at 6:01
  • What languages are you using in your other application? Feb 21, 2017 at 6:33
  • Yes, Try the code in my answer, it should work. Feb 21, 2017 at 6:47
  • 1. Using REST : I get this error when i run "Uncaught ReferenceError: _spPageContextInfo is not defined"
    – Admin
    Feb 21, 2017 at 6:49
  • try giving full url of sharepoint site instead of it. var siteURL = "http://<your site name>/_api/web/GetFolderByServerRelativeUrl('"+LibName+"')/Files Feb 21, 2017 at 6:53

Your Answer

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

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