Hello Techies,
For some analysis, I must retrieve all the pages from SPO classic along with the layout attached to it and the numbers of webparts that page has.
I wrote this basic code, however I am unable to proceed further for pagelayouts and webparts
var clientContext = GetonlineContext(sitecollectionURL);
Web oWeb = clientContext.Web;
List oPages = clientContext.Web.Lists.GetByTitle("Pages");
ListItemCollection oColl = oPages.GetItems(CamlQuery.CreateAllItemsQuery());
clientContext.Load(oColl);
clientContext.Load(oWeb, w => w.Title, w => w.Webs, w => w.Lists, w => w.Url);
clientContext.ExecuteQuery();
foreach(ListItem item in oColl)
{
clientContext.Load(item, (System.Linq.Expressions.Expression<Func<ListItem, object>>)item.FieldValues["PublishingPageLayout"]);
clientContext.ExecuteQuery();
Console.WriteLine("File Ref: " + item["FileRef"]);
Console.WriteLine("Page Layout: " + ((FieldUrlValue)item.FieldValues["PublishingPageLayout"]).Description);
}