I have a requirement to add a Client Webpart from a provider hosted app, onto a page in the Host Web its deployed to. I have tried using the Client Object Model's Limited WebPart Manager to achieve this, but that only works for xml data that are part of .dwp or .webpart files. I have used the below code. Is there a workaround this, to get the App Part files from a site and add them to a Sharepoint Page?
ClientContext clientconteext = new ClientContext("My Server URL");
Microsoft.SharePoint.Client.File page = clientconteext.Web.GetFileByServerRelativeUrl("/sites/MySite/SitePages/Home.aspx");
clientconteext.Load(clientconteext.Web);
clientconteext.Load(page);
clientconteext.ExecuteQuery();
LimitedWebPartManager lwp= page.GetLimitedWebPartManager(PersonalizationScope.Shared);
string webpartxml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Elements xmlns=\"http://schemas.microsoft.com/sharepoint/\"><WebPartPages:ClientWebPart runat=\"server\" FeatureId=\"5b1a14dd-8dbe-4963-8612-e7918e7fbc9a\" ProductWebId=\"5b1a14dd-8dbe-4963-8612-e7918e7fbc9a\" WebPartName=\"HomePageAppPart\" Title=\"Home App Part\" Description=\"WebPart Description\" WebPart=\"true\"></WebPartPages:ClientWebPart></Elements>";
WebPartDefinition wpd = lwp.ImportWebPart(webpartxml);
lwp.AddWebPart(wpd.WebPart, "Right", 1);
clientconteext.ExecuteQuery();