I have to add a few webparts to a default page using the Client side object model. For the most part this goes fine, I can add a XSLT and content query webparts.
However, when i try to add a ListViewWebPart, I get the exceedingly helpful "Unknown Error" I use the following code to add the webpart
Microsoft.SharePoint.Client.File oFile = context.Web.GetFileByServerRelativeUrl(newWeb.ServerRelativeUrl + "/default.aspx");
LimitedWebPartManager limitedWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared);
WebPartDefinition webDef = limitedWebPartManager.ImportWebPart(webPartXmlString));
limitedWebPartManager.AddWebPart(webDef.WebPart, "Right", 0);
context.ExecuteQuery();
and the following XML
<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
<Title>Agenda</Title>
<FrameType>Default</FrameType>
<Description />
<IsIncluded>true</IsIncluded>
<ZoneID>Right</ZoneID>
<PartOrder>1</PartOrder>
<FrameState>Normal</FrameState>
<Height />
<Width />
<AllowRemove>true</AllowRemove>
<AllowZoneChange>true</AllowZoneChange>
<AllowMinimize>true</AllowMinimize>
<AllowConnect>true</AllowConnect>
<AllowEdit>true</AllowEdit>
<AllowHide>true</AllowHide>
<IsVisible>true</IsVisible>
<DetailLink>/Lists/Agenda</DetailLink>
<HelpLink />
<HelpMode>Modeless</HelpMode>
<Dir>Default</Dir>
<PartImageSmall />
<MissingAssembly>Kan dit webonderdeel niet importeren.</MissingAssembly>
<PartImageLarge>/_layouts/15/images/itevent.png?rev=32</PartImageLarge>
<IsIncludedFilter />
<Assembly>Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
<WebId xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">00000000-0000-0000-0000-000000000000</WebId>
<ListViewXml xmlns="http://schemas.microsoft.com/WebPart/v2/ListView"><View MobileView="TRUE" Type="CALENDAR" Hidden="TRUE" TabularView="FALSE" Scope="Recursive" RecurrenceRowset="TRUE" DisplayName="" Url="/default.aspx" Level="1" BaseViewID="2" ContentTypeID="0x" MobileUrl="_layouts/15/mobile/viewdaily.aspx" ImageUrl="/_layouts/15/images/events.png?rev=33"><ViewFields><FieldRef Name="EventDate" /><FieldRef Name="EndDate" /><FieldRef Name="Title" /><FieldRef Name="fRecurrence" Explicit="TRUE" /></ViewFields><CalendarViewStyles>&lt;CalendarViewStyle Title='Dag' Type='day' Template='CalendarViewdayChrome' Sequence='1' Default='TRUE' /&gt;&lt;CalendarViewStyle Title='Week' Type='week' Template='CalendarViewweekChrome' Sequence='2' Default='FALSE' /&gt;&lt;CalendarViewStyle Title='Maand' Type='month' Template='CalendarViewmonthChrome' Sequence='3' Default='FALSE' /&gt;</CalendarViewStyles><Aggregations Value="Off" /><RowLimit>0</RowLimit><Mobile MobileItemLimit="3" /><Toolbar Type="Standard" /><ViewHeader /><ViewBody /><ViewFooter /><ViewEmpty /><ParameterBindings><ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /><ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" /></ParameterBindings><ViewData><FieldRef Name="Title" Type="CalendarMonthTitle" /><FieldRef Name="Title" Type="CalendarWeekTitle" /><FieldRef Name="Location" Type="CalendarWeekLocation" /><FieldRef Name="Title" Type="CalendarDayTitle" /><FieldRef Name="Location" Type="CalendarDayLocation" /></ViewData><Query><Where><DateRangesOverlap><FieldRef Name="EventDate" /><FieldRef Name="EndDate" /><FieldRef Name="RecurrenceID" /><Value Type="DateTime"><Month /></Value></DateRangesOverlap></Where></Query></View></ListViewXml>
<ListName xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">{{GUID}}</ListName>
<ListId xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">{GUID}</ListId>
<ViewFlag xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">11022345</ViewFlag>
<ViewFlags xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">Html Hidden Recursive RecurrenceRowset Calendar FilesOnly Mobile</ViewFlags>
<ViewContentTypeId xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">0x</ViewContentTypeId>
</WebPart>
The XML is generated by exporting a sharepoint list webpart, and i can import it through the Gui just fine. (Naturally the {GUID} is replaced with the actual List Id)
Does anyone have any idea what could cause the Unknown error, or at least how i could debug this?