0

I want to add/remove users from SharePoint group when excel file uploaded by admin person using rest odata or angular.

Can any one please help me in this requirement?

4
  • Please provide more information! Does the excel file contains the data about the users that needs to be added/remove from SharePoint group? Commented Oct 21, 2018 at 17:59
  • Yes I have excel file in which contains users email ids and based on that i want to add users into group or remove it. Commented Oct 22, 2018 at 6:29
  • Yes I have excel file in which contains users email ids and based on that i want to add users into group or remove it. Commented Oct 22, 2018 at 6:30
  • Please refer to my answer. Hope it helps! Commented Oct 22, 2018 at 12:17

1 Answer 1

0

Firstly you will have to read the data from excel (let's say by CSOM) and save it in the lists.

From the list, read the data using REST API and store it in variable.

Then pass the user name dynamically to

Add user to group:

    executor.executeAsync({
  url: "<app web url>/_api/SP.AppContextSite(@target)/web
    /sitegroups(7)/users
    ?@target='<host web url>'",
  method: "POST",
  body: "{ '__metadata': { 'type': 'SP.User' }, 'LoginName':'i:0#.w|domain\\user' }",
  headers: {
    "accept": "application/json; odata=verbose",
    "content-type": "application/json; odata=verbose"
  },
  success: successHandler,
  error: errorHandler
});

Reference

Remove user from group:

    executor.executeAsync({
  url: "<app web url>/_api/SP.AppContextSite(@target)/web/sitegroups(7)/users
    /removebyloginname(@v)?@v='i%3A0%23.f%7Cmembership%7Cuser%40domain.onmicrosoft.com'
    &@target='<host web url>'",
  method: "POST",
  success: successHandler,
  error: errorHandler
});

Reference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.