CSOM Publishing Page SharePoint Issue

%3CLINGO-SUB%20id%3D%22lingo-sub-813367%22%20slang%3D%22en-US%22%3ECSOM%20Publishing%20Page%20SharePoint%20Issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-813367%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20call%20the%20%22ExecuteQuery%22%20method%20on%20the%20context%20immediately%20after%20calling%20the%20%E2%80%9CAdd%E2%80%9D%20method%20on%20the%20%22FileCollection%22%20and%20the%20%3CSTRONG%3Efile%20does%20get%20created%3C%2FSTRONG%3Ebut%20%3CSTRONG%3ESharePoint%20returns%20the%20error%3C%2FSTRONG%3Emessage%20included%20below.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EError%20Message%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EMicrosoft.SharePoint.Client.ServerException%3A%20The%20file%20%22%5BREDACTED%5D%2FPages%2FHome.aspx%22%20is%20not%20checked%20out.%20You%20must%20first%20check%20out%20this%20document%20before%20making%20changes.%3C%2FP%3E%3CP%3Eat%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream%20responseStream)%3C%2FP%3E%3CP%3Eat%20Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()%3C%2FP%3E%3CP%3Eat%20Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder%20sb)%3C%2FP%3E%3CP%3Eat%20Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-813367%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPIs%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-814185%22%20slang%3D%22en-US%22%3ERe%3A%20CSOM%20Publishing%20Page%20SharePoint%20Issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-814185%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F395327%22%20target%3D%22_blank%22%3E%40tpalacino%3C%2FA%3E%26nbsp%3BCould%20you%20please%20%3CSPAN%3Ego%20to%20the%20document%20library%20which%20host%20these%20contents%2C%20and%20click%3C%2FSPAN%3E%3CSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3ELibrary%26gt%3BLibrary%20settings%26gt%3Bversioning%20settings%3C%2FSTRONG%3E%3CSPAN%3E.%20Here%2C%20set%20it%20to%20no%20for%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ERequire%20documents%20to%20be%20checked%20out%20before%20they%20can%20be%20edited%3C%2FSTRONG%3E%3CSPAN%3E.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%20me%20know%20if%20this%20works.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-814209%22%20slang%3D%22en-US%22%3ERe%3A%20CSOM%20Publishing%20Page%20SharePoint%20Issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-814209%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394813%22%20target%3D%22_blank%22%3E%40Vikram_Samal%3C%2FA%3E%26nbsp%3BThanks.%20That%20might%20be%20a%20way%20to%20work%20around%20this%20error%20in%20the%20short%20term.%20There%20is%20still%20something%20fundamentally%20wrong%20though%20when%20given%20a%20list%20instance%2C%20calling%20the%20add%20method%2C%20and%20executing%20only%20that%20operation%20results%20in%20(a)%20the%20operation%20being%20successful%20and%20(b)%20the%20system%20returning%20an%20error%20message.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIMO%20it%20would%20be%20absolutely%20ridiculous%20for%20a%20platform%20to%20require%20a%20settings%20change%20in%20order%20to%20get%20a%20response%20that%20is%20consistent%20with%20the%20behavior.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

We call the "ExecuteQuery" method on the context immediately after calling the “Add” method on the "FileCollection" and the file does get created but SharePoint returns the error message included below.

 

Error Message:

Microsoft.SharePoint.Client.ServerException: The file "[REDACTED]/Pages/Home.aspx" is not checked out. You must first check out this document before making changes.

at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)

at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()

at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)

at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()

2 Replies
Highlighted

@tpalacino Could you please go to the document library which host these contents, and click Library>Library settings>versioning settings. Here, set it to no for Require documents to be checked out before they can be edited.

 

Let me know if this works.

Highlighted

@Vikram_Samal Thanks. That might be a way to work around this error in the short term. There is still something fundamentally wrong though when given a list instance, calling the add method, and executing only that operation results in (a) the operation being successful and (b) the system returning an error message.

 

IMO it would be absolutely ridiculous for a platform to require a settings change in order to get a response that is consistent with the behavior.