I am facing this issue while trying to add users to SP group using REST and Jquery.

While adding the user prompt comes asking for username and password, after I enter my credentials it does not authenticate, but after canceling this prompt error comes saying

"you do not have permission to perform this action"

Again when I check in the group the users has been added already. I am able to perform delete action without any issue.

here is my code below.

function addUsers(name)
    var loginName = name.split('|')[1].split('\\'); 
    var domain = loginName[0]; 
    var userid = loginName[2]; 
    var requestUri = varSiteUrl + "_api/web/sitegroups(" + $("#ddlgroup").val() + ")users";
    url: requestUri,
     type: "POST",
     data: JSON.stringify({ '__metadata': { 'type': 'SP.User' }, 'LoginName': domain + '\\' + userid }),
    headers: { "accept": "applicationjson;odata=verbose", "content-type": "applicationjson;odata=verbose", "X-RequestDigest": data.d.GetContextWebInformation.FormDigestValue },
    success: onSuccess, error: onError

This is working properly with Site collection Admin access but does not work with Full control access.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.