I'm trying to unpublish the last published version of a file(Page) when there is a draft version of it.
It is possible with OOTB UI.
SPFile.TakeOffline (Server Object Model) method can be used to do this. I'm looking for a CSOM (Client Object Model) equivalent for this method or fill the requirement.
Below is the OOTB behavior.
Unpublish 1.0 when there is a 1.1
1.0 becomes 0.2 when unpublished.
Requirement: Unpublish the last Major/Published file Version when there is a Draft version of it.
<site url>/_api/web/getfilebyserverrelativeurl(<relative file path>)/unpublish(comment='done')
gives below error because there is a draft version at last.
“You can only Unpublish a major version or approved document. Or Cancel publish for a pending document.”
Even File.UnPublish CSOM gave the same error.