3.2.5.146.2.2.2 ImportWebPart

Return Type: Microsoft.SharePoint.Client.WebParts.WebPartDefinition

Imports a Web Part from a string in the .dwp format as specified in [MS-WPPS] section 2.2.4.2, or the .webpart format as specified in [MS-WPPS] section 2.2.3.1. After importing, the Web Part is not added to a Web Part Page. To add a Web Part to a Web Part Page, use AddWebPart, supplying the object (1) returned by this method. A reference to the added SP.WebParts.WebPartDefinition is returned.

When Scope is User, the current user MUST have permissions to add and delete personalized Web Parts. When Scope is Shared, the current user MUST have permissions to customize pages.

Parameters:

webPartXml: The Web Part markup to import.

Type: CSOM String

It MUST NOT be NULL. It MUST NOT be empty. It MUST be valid XML in the .dwp or .webpart format.

Exceptions:

Error Code

Error Type Name

Condition

-1

Microsoft.SharePoint.WebPartPages.WebPartPageUserException

The provided Web Part markup is not in the .dwp or .webpart format.