Frage

I am using python with the sharepy module to make requests to sharepoint. I would really like to know to get get all of the folders, subfolders, and files of a sharepoint site via a http request. I can list folders and files like so:

r = s.get(spo_site + """_api/web/GetFolderByServerRelativeUrl('""" + root_folder + """')/Folders""")

But it need it to go deep into the folder structure to get the relative urls and names of the files and folders. I would think this would be possible considering most sites have an export to excel button. The reason I want to do this with code because I need to go through a bunch of sites. Please Help.

EDIT
Mike Smith response answered my question. My code is like this:

r = s.get(spo_site + """_api/web/lists/getbytitle('Documents')/items?$select=FileLeafRef,FileRef&$top=5000)

This works great but the limit is 5000 items. I am going to need much more than this. Is there a solution for this?

War es hilfreich?

Lösung

A CAML query may work. If multiple calls are ok then:

You can get a list of libraries using:

_api/web/lists?$filter=BaseTemplate eq 101

Note that 101 is for the Document Library template. A long list of template IDs here: https://techtrainingnotes.blogspot.com/2015/02/sharepoint-2013-list-and-library.html

And then from the list of libraries, get every folder/file using:

_api/Lists/getbyTitle('Documents')/Items?$select=FileLeafRef,FileRef,Id
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top