office365wspsharepoint-online

Activate a solution (.wsp) programmatically in Office 365 (Sharepoint online) site collection


I have a .wsp file uploaded into the Solution Gallery of a site collection created in Office 365. This solution is not activated and I want to activate it programmatically. The below code is an example on how to achieve it for a solution file in an on premise sharepoint site.

SPDocumentLibrary solutionGallery = (SPDocumentLibrary)siteCollection.GetCatalog(SPListTemplateType.SolutionCatalog);
SPFile file = solutionGallery.RootFolder.Files.Add("HelloWorldSolution.wsp", File.ReadAllBytes("HelloWorldSolution.wsp"));
// Activating the solution file 
SPUserSolution solution = siteCollection.Solutions.Add(file.Item.ID);

Is there a sharepoint online(Office 365) equivalent of this, that can be achieved through the client object model in CSOM?


Solution

  • Use this, It has neat explanation. You can use webclient Api to do that job http://blog.symprogress.com/2013/07/upload-wsp-file-to-office365-sp2013-using-webclient/