SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the best way to get a list of all the file names in a sharepoint document library with javascript?

share|improve this question
up vote 2 down vote accepted

Apparently there's a property called FileLeafRef, and I could query the library like so...

            url: "site.url/_api/web/lists/getByTitle('LibraryName')/items?$top=1000&$select=FileLeafRef",
            type: "GET",
                           "accept": "application/json;odata=verbose"
            success: filesuccess,
            error: error
share|improve this answer

try this:

        url: "site/_api/web/GetFolderByServerRelativeUrl('Documents')/Files",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function(data){
            for(var i = 0; i<data.d.results.length; i++){
                var result data.d.result[i];
        error: errorListHandler

function errorListHandler(){

In var result you have information about the file[i] of the array of files

share|improve this answer
Including the name of file, URL, Size and more... – Diego Hillesheim Nov 21 '13 at 16:24
If help mark with answer. Tanks! – Diego Hillesheim Nov 21 '13 at 17:58

You can make use of CAML query to fetch the values as below,

var caml = "<View><ViewFields><FieldRef Name='Title'/></ViewFields></View>

Or you can make use of


Have a look at the below link,

Get List items using Jquery

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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