How to export web part in Sharepoint Online Using CSOM?

Hello SharePointers,

In this blog ,we will see how to export web part in SharePoint Online using CSOM code.

using (ClientContext ctx = new ClientContext(“”)) {
SecureString password = new SecureString();

ctx.Credentials = new SharePointOnlineCredentials(“”, password);
File file = ctx.Web.GetFileByServerRelativeUrl(“/pages/mycustom.aspx”);
LimitedWebPartManager mgr= file.GetLimitedWebPartManager(PersonalizationScope.Shared);
Guid webPartId = new Guid(“your GUID”);
ClientResult webPartXml = mgr.ExportWebPart(webPartId);

Happy SharePointing 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *