0

I tried the below code

Microsoft.SharePoint.Client.File home = ctx.Web.GetFileByServerRelativeUrl("/Sites/SiteName/Style Library/JS/app.js");
if (home.CheckOutType != CheckOutType.None)
{
   home.CheckIn(string.Empty, CheckinType.MajorCheckIn);
}

home.CheckOutType is throwing an error as that property is not initialized

Message "The property or field 'CheckOutType' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested." string

Will it not work in O365?

1

You need to load the file first before checking it in. Try the below code:

Microsoft.SharePoint.Client.File home = ctx.Web.GetFileByServerRelativeUrl("/Sites/SiteName/Style Library/JS/app.js");

ctx.Load(home);
ctx.ExecuteQuery();


if (home.CheckOutType != CheckOutType.None)
{
   home.CheckIn(string.Empty, CheckinType.MajorCheckIn);
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.