I have a list in SharePoint on Premise in which I know there are 2 files and a folder. If I try to get the list of files from it I always get an empty response like in the example:

GET :url/web/GetFolderByServerRelativeUrl('/Documents')/Files

  "d": {
    "results": []

I know from a call to GET :url/web/GetFolderByServerRelativeUrl('/Documents')/Properties that the list has 3 items (the 2 files and a folder) but neither the files nor the folders appear when I call through the REST interface (they appear on the web though).

Any idea on where to start debugging this?

If I repeat the same call from the browser after authenticating as a user I get a response with the files/folders I expect.


More details, The app is a provider hosted high-trust app. I use a JWT token to authenticate the user (through active directory) generated as explained here https://msdn.microsoft.com/en-us/library/office/dn762439.aspx


url: is https://spop-domain.com/_api


I've tried different users to make sure it was not the user I was tryint. I've also tried creating a new application in SharePoint and using a new certificate to sign the tokens. None of those did work. I'm still getting an empty list of results on /Files, /Folders and /Items while the list details sais that ItemCount is 3 (2 files and a folder).

  • Are the files actually located in the library that has the folder address /Documents ? Your code works fine for me (provided I sub url/web/... with /_api/web). It's possible that the library name and its URL are quite different. – John-M Sep 25 '15 at 14:41
  • Yes, they do, sorry, forgot to comment that :url is in fact domain/_api however, I know for sure that the files are there and the api can return them because I can get them by making a get just from the browser once I'm authenticated on the on-premise server. – Francisco Sep 25 '15 at 14:52
  • 1
    If you go to a webpage on your host web and do a Javascript request in your browser dev tools like $.getJSON("/_api/web/getfolderbyserverrelativeurl('/Documents')/Files", function(data) { console.log(data) }) does it have any data in the results? – John-M Sep 25 '15 at 14:56
  • Then I get the results I am expecting (the 2 files). – Francisco Sep 25 '15 at 15:12
  • 1
    Thanks for the link. I already had a look into it, but my app is a ruby on rails backend app, I'm doing all the calls from the ruby code, no javascript involved. I'm sure that the host is the right one since I can get the info with the same call from the browser instead of the ruby code. The only difference is that the ruby code authenticates through a token while calling from the browser uses the existing cookie from sharepoint. Oh, and tons of thanks both @John-M and you for your replies :) – Francisco Sep 25 '15 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.