0

When I go to a specific folder in Sharepoint, I hit an error that I have exceeded the view threshold of 5000 items. I created a new view to only show items when the ID < 5000, I am able to see the folder contents now.

However, how do I apply a specific view/filter when using Python?

Using Python's request module, I have:

requestUrl = sharePointUrl + "/{0}/_api/web/GetFolderByServerRelativeUrl('/{0}/{1}')/Files".format(site, folder)
headers={'Content-Type': 'application/json; odata=verbose', 'accept': 'application/json;odata=verbose'}
requests.get(requestUrl , headers=headers).json()

which returns {'d': {'results': []}}

If I modify the requestUrl to include ?$top=1000 or ?$filter=Id lt 1000, I still have an empty result (no throttled error, just empty result)

How do I apply the filters correctly or use a specific view when running the request query?

(I used a different folder name and I get an error 'Field or property "Id" does not exist.' so clearly something is wrong with my query too but I am not sure why the other folder returns empty result and not an error)

Bijan
  • 7,737
  • 18
  • 89
  • 149

1 Answers1

0

just having a first glance on it and looking at this line

requestUrl = sharePointUrl + "/{0}/_api/web/GetFolderByServerRelativeUrl('/{0}/{1}')/Files".format(site, folder)

it will seem like the URL you want to create might be wrong. I think you should not add site to the GetFolderByServerRelativeUrl as you already will be running this in the context of the site. So for example if your site is sites/someSite and folder is shared documents you will have

sites/someSite/_api/web/GetFolderByServerRelativeUrl('/sites/someSite/shared documents')/Files

but I think you should have something like

sites/someSite/_api/web/GetFolderByServerRelativeUrl('shared documents')/Files

could you give it a double check?

Adam
  • 810
  • 7
  • 10