Forum Discussion
Arun C
Jun 30, 2017Copper Contributor
Activate Site Feature through REST API
I'm trying to activate site level feature by using REST API in SharePoint Hosted App. I've given full control at Site Collection & Site level with App only Calls. But I'm getting "Access Denied Error...
Jun 30, 2017
Hi Arun C
I would look into PnP-Js-Core.
import pnp from "sp-pnp-js"; let web = pnp.sp.web; // activate the minimum download strategy feature web.features.add("87294c72-f260-42f3-a41b-981a2ffce37a").then(f => { console.log(f); });
https://github.com/SharePoint/PnP-JS-Core/wiki/Working-With:-Features
Arun C
Jul 11, 2017Copper Contributor
Hi Pieter Veenstra,
Thanks for your comment..
I've tried the same within SHA, But still facing issues.s
Code:
$pnp.sp.crossDomainWeb(addinweb, hostweb).get().then(function (success) { success.web.features.add("a7a2793e-67cd-4dc1-9fd0-43f61581207a").then(r => { console.log(r); }).catch(function (err) { console.log(err); }); }).catch(function (err) { console.log(err); });
I'm getting error
TypeError: Cannot read property 'features' of undefined
- Jul 11, 2017
Does instead of
$pnp.sp.crossDomainWeb(addinweb, hostweb).get().....
maybe somethign like this work:
$pnp.sp.crossDomainWeb(addinweb, hostweb).features........
- Arun CJul 11, 2017Copper ContributorI've tried the same, but getting error
"Cannot read property 'add' of undefined"