i seen a ton of examples adding ContentEditorWebpart to publishing page, which i tried and works great.

my question is is there a way to ScriptEditorWebpart to publishing page using CSOM.

Changing the


tag to


which in essence should work because both extend Microsoft.SharePoint.WebPartPages.Webpart Class

however i get and error in the PostQuery Response this is it:

[ { "SchemaVersion":"", "LibraryVersion":"15.0.4569.1501", "ErrorInfo": {"ErrorMessage": "The Microsoft.SharePoint.WebPartPages.ScriptEditorWebPart class does not derive from the Microsoft.SharePoint.WebPartPages. WebPart class and therefore cannot be imported or used in a WebPartZone control.", "ErrorValue":null, "TraceCorrelationId":"980cca9d-f009-a078-9fca-b6f367086a64", "ErrorCode":-1, "ErrorTypeName":"Microsoft.SharePoint.WebPartPages.WebPartPageUserException" }, "TraceCorrelationId":"980cca9d-f009-a078-9fca-b6f367086a64" } ]

1 Answer 1


ScriptEditor uses different xml schema, http://schemas.microsoft.com/WebPart/v3, that's why it's not possible to just change the type name.
For script editor you need following xml:

  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
      <type name="Microsoft.SharePoint.WebPartPages.ScriptEditorWebPart, Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
        <property name="ExportMode" type="exportmode">All</property>
        <property name="HelpUrl" type="string" />
        <property name="Hidden" type="bool">False</property>
        <property name="Description" type="string">Allows authors to insert HTML snippets or scripts.</property>
        <property name="Content" type="string">&lt;div&gt;my content goes here&lt;/div&gt;</property>
        <property name="CatalogIconImageUrl" type="string" />
        <property name="Title" type="string">Script Editor</property>
        <property name="AllowHide" type="bool">True</property>
        <property name="AllowMinimize" type="bool">True</property>
        <property name="AllowZoneChange" type="bool">True</property>
        <property name="TitleUrl" type="string" />
        <property name="ChromeType" type="chrometype">None</property>
        <property name="AllowConnect" type="bool">True</property>
        <property name="Width" type="unit" />
        <property name="Height" type="unit" />
        <property name="HelpMode" type="helpmode">Navigate</property>
        <property name="AllowEdit" type="bool">True</property>
        <property name="TitleIconImageUrl" type="string" />
        <property name="Direction" type="direction">NotSet</property>
        <property name="AllowClose" type="bool">True</property>
        <property name="ChromeState" type="chromestate">Normal</property>

I can recommend you an easiest way to quickly import any web part from the page to see the actual web part xml. You need Google Chrome and bookmarklet feature. Chrome allows you to run certain javascript code when you click on bookmark. The trick is to create special bookmark with javascript code, which is responsible to export web parts from page:

  1. In Chrome click Control (top right corner) -> Bookmarks -> Bookmarks manager.
  2. Right click - Add Page
  3. For Name type "Export WPs"
  4. For Url past whole script from here - https://raw.githubusercontent.com/mirontoli/sp-lend-id/master/pajla/bookmarklet.html and press Enter.
  5. On any SharePoint web site click on "Export WPs" bookmark and you will be presented with dialog with all web parts available. Click on desired web part to export.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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