string adminUrl = "https://delve-admin.sharepoint.com"; using (var context = new ClientContext(adminUrl)) { context.Credentials = new SharePointOnlineCredentials(userName, securePassword); SearchConfigurationPortability searchConfig = new SearchConfigurationPortability(context); SearchObjectOwner owner = new SearchObjectOwner(context, SearchObjectLevel.SPSiteSubscription); string xml = System.IO.File.ReadAllText("SearchConfiguration.xml"); searchConfig.ImportSearchConfiguration(owner, xml); context.ExecuteQuery(); }
If you are using OfficePnP then you get away with the following snippet
string adminUrl = "https://delve-admin.sharepoint.com"; using (var context = new ClientContext(adminUrl)) { context.Credentials = new SharePointOnlineCredentials(userName, securePassword); context.ImportSearchSettings("SearchConfiguration.xml", SearchObjectLevel.SPSiteSubscription); }