I am creating termset in SharePoint Hosted App with below code. but it is giving error Access denied. You do not have permission to perform this action or access this resource. Whereas logged in user is owner for that group where i am creating this termset.
createTerm: function (termName) {
var _this = this;
//Current Context
var context = SP.ClientContext.get_current();
//Current Taxonomy Session
var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
//Term Stores
var termStores = taxSession.get_termStores();
//Term Store under which to create the term.
var termStore = termStores.getByName(_this.termStoreName);
//Term Set under which to create the term.
var termSet = termStore.getTermSet(_this.termSetId);
//Create new guid
var termGuid = new SP.Guid.newGuid()
//Name of the term, LCID and a new GUID for the term.
var newTerm = termSet.createTerm(termName, 1033, termGuid.toString());
newTerm.set_isAvailableForTagging(true);
context.load(newTerm);
context.executeQueryAsync(function (sender, args) {
_this.termMetadataString = termName + ";" + termGuid.toString();
_this.upsertAuditFormItem("Term Metadata string");
}, function (sender, args) {
console.log(args.get_message())
alert("Here it is throwing error. Which i mentioned earlier");
AuditUtility.hideLoading();
});
},