In this blog, we will be learning about activation of SharePoint feature using REST API.
So, lets get started - I will show you how to activate SharePoint feature using REST API.
I have created simple JavaScript code to activate the feature.
function activateFeature() {
$.ajax({
url: _spPageContextInfo.siteAbsoluteUrl +
"/_api/web/features/add('7e2e2482-9007-4db3-8a7f-9bccd986ec4e')",
type: "POST",
headers: {
"Accept": "application/json;odata=verbose", //return data format.
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function(data) {
// perform operation on the response object.
},
error: function(err) {
alert("Error: " + JSON.stringify(err));
}
});
}
Change the URI, and the feature will be activated based on the endpoint.
Now, pass the feature GUID into the add method. You can get the GUID value by using the PowerShell command or by "SharePoint Manager 2013".
- /web - then feature will be activated at the web level.
- /site - then feature will be activated at the site collection level.
Now, pass the feature GUID into the add method. You can get the GUID value by using the PowerShell command or by "SharePoint Manager 2013".
I hope this will help all of you! 🧲
Feel free to provide feedback.
🚀 "Happy Coding" 🚀