I have to make a SharePoint-hosted-app for creating subsites and applying a theme on created subsites programmatically.
my app is installed on root site (site collection) and I want to change subsites theme(change subsite looks) from this app.
But when I exceute the applyTheme function I receive below error:
Here is my fucntion:
function ApplyTheme() {
var clientContext = new SP.ClientContext(subSiteUrl);
var web = clientContext.get_web();
var colorPaletteUrl = subSiteUrl + "/_catalogs/theme/15/palette011.spcolor";
var fontSchemeUrl = subSiteUrl + "/_catalogs/theme/15/fontscheme002.spfont";
var backgroundImageUrl = imageUrl;
var shareGenerated = true;
web.applyTheme(colorPaletteUrl, fontSchemeUrl, backgroundImageUrl, shareGenerated);
web.update();
clientContext.executeQueryAsync(onApplyThemeSuccess, OnFailure);
}
even i tried this way, but it doesn't work too:
var api = subSiteUrl "/_api/web/applyTheme([parameters])";
var executor = new SP.RequestExecutor(appweburl);
executor.executeAsync ({
url: api,
method: "POST",
headers: { "Accept": "application/json; odata=verbose" },
success: onApplyThemeSuccess,
error: OnFailure
});
have you any idea or solution?
Thank for your helps!