Forum Discussion
How to get all the checked out files in a library with rest
How to get the checked out files of all user with rest.
I just ran a test and this pulled back checked out items in a library in SharePoint Online:
/_api/web/lists/getbytitle('Documents')/items?$filter=CheckoutUserId ne null
- Sebastián Acevedo FlórezCopper Contributor
That only retrieves the files that I checked out. I need to see all the files checked out by everyone
I just ran this against a document library with files checked out from 2 different people and it returned both items:
/_api/web/lists/getbytitle('Documents')/items?$select=CheckoutUserId/Title&$filter=CheckoutUserId ne null
Screenshot of results:
- Michelle PorrecaIron Contributor
Are you sure that the files have been checked in before. It may be that you cannot see files that are checked out because the files have never been checked in. Once the initial check in has happened, it becomes visible to all users, even if it's subsequently checked out.
- Sebastián Acevedo FlórezCopper Contributor
Yes, because he will see the last checked in version. But I need to see the first checked out file. The ManageCheckedOutFiles.aspx page allows me to see all check out files (including first checked out files)
- Chris GullicksenIron ContributorHello,
Is there a reason you need to do this with the rest api? I was curious as I know this sort of task can be handled with a SharePoint view in the library by showing the "checked out to" column. The only other catch to this is the new files that were uploaded and not checked in for the first time that can be caught in the Library Settings > Managed files with no checked in version page.You are right files with no checked in version that were not uploaded by you are not visible via REST (as far as I can find via testing). What is your use case to find these files? You could probably write a script to get this using CSOM.
- SecretAsianManCopper Contributor
Sebastián Acevedo Flórez have you gotten an answer to this? I am looking for solution to this as well. Need to see all checked out files (to include initial upload checked out by another user/no checked in version). Thank you.
- MartinZamazal1980Copper ContributorLate to the party, but hope it can help someone. If you want to look up files with no previous check in versions (which are displayed in the ManageCheckedOutFiles.aspx page), you can use REST API and GetCheckedOutFiles().
https://contoso.sharepoint.com/sites/sitename/_api/web/lists/GetByTitle('ListTitle')/GetCheckedOutFiles()
It works at least in SharePoint Online. It will return only files with no check in versions, but not regular checked out files.