This SharePoint 2013 tutorial we will discuss how to solve the file is not checked out. you must first check out this document before making changes. You must first check out this document before making changes error which comes in SharePoint Online/2013/2016 CSOM.
Recently we were working on a SharePoint online site where we needed to upload a few files to a document library. Here we were using SharePoint provider hosted apps or add-in, in that add-in on a button click we were copying those files to the document library.
As we know we can not execute any server-side code inside SharePoint online, we were using .Net managed object model code (csom).
To work with .net managed object model code we need to add below dlls which we can add from NuGet packages.
- Microsoft.SharePoint.Client.dll
- Microsoft.SharePoint.Client.Runtime.dll
When we execute code to copy files to SharePoint online document library, we got the below error which says:
The file “https://SiteURL/Document_Library_Name/Archiving16.gif” is not checked out. You must first check out this document before making changes.

The file is not checked out. You must first check out this document before making changes
One solution is programmatically, you can first check out the file if it already exists and then after finishing the upload you can check-in the file.
But in our case we have checked in the document library, someone mistakenly enables “Create major and minor (draft) versions” in Document Version History of the document library.
So you can go to the Library Settings -> Versioning Settings and in the Versioning Settings page you can disable the Versioning or you can also create major versions like below:

the file is not checked out SharePoint
You may get the file is not checked out error while trying to edit a document in SharePoint Online/2016/2013 document library, if “Require documents to be checked out before they can be edited?” option is enabled in the document library.
To verify if Require Check out is enabled, Open the SharePoint document library, go to the library settings and then click on Versioning Settings.
In the Versioning Settings page, you can see if Require documents to be checked out before they can be edited? is Yes/No.
Make sure, the option should be selected as No, then the file is not checked out SharePoint error will not come.

the file is not checked out. you must first check out this document before making changes.
Unable to Check File Out SharePoint
I was also trying to check out the file using csom in SharePoint by using the below code:
using (var ctx = new ClientContext("http://SharePoit Site URL"))
{
var web = ctx.Web;
var file = web.GetFileByServerRelativeUrl("TeamSite/HRDocuments/leavepolicy.pdf");
file.CheckOut();
ctx.ExecuteQuery();
}
But I get error like below:
The file ‘http://SharePoit Site URL/TeamSite/HRDocuments/leavepolicy.pdf’ is not checked out. this case, you need to lead the file first and then you can check out the file.
using (var ctx = new ClientContext(_sitename))
{
var web = ctx.Web;
var file = web.GetFileByServerRelativeUrl(serverRelativeUrl);
ctx.Load(file);
file.CheckOut();
ctx.ExecuteQuery();
}
the file is not checked out you must first check out this document
If you are getting the same issue “the file is not checked out you must first check out this document“, Check if the document is currently locked by any user? Or any other use is already check out the file.
Read some SharePoint 2013 csom tutorials:
- Steps to add items from csv file to SharePoint Online List using PowerShell in CSOM
- Content type Examples using CSOM in SharePoint Online/2013/2016
- SharePoint create workflow history list programmatically using client side object model code (csom)
- SharePoint 2016 CSOM Check if Column Exists or Not in SharePoint List
- Copy SharePoint list items to another list programmatically using CSOM in SharePoint Online/2013/2016
- Create a list from list template in SharePoint Online 2013 programmatically
- CAML Query for SharePoint Boolean Field using SharePoint Online Client Object Model (CSOM)
- SharePoint Online: Create an indexed column in a list Programmatically using CSOM .Net managed object model code using visual studio 2017/2015
- Hide SharePoint List Title Column Programmatically using PnP CSOM
Now the file is not checked out. you must first check out this document before making changes. You must first check out this document before making changes issue will not come. Hope this will be helpful.
Hello Everyone!! I am Bhawana a SharePoint MVP and having about 10+ years of SharePoint experience as well as in .Net technologies. I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools. Now exploring more in SharePoint 2016 🙂 Hope here I can contribute and share my knowledge to the fullest. As I believe “There is no wealth like knowledge and no poverty like ignorance”