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?

  • Please provide more information! Does the excel file contains the data about the users that needs to be added/remove from SharePoint group? – Sohail Shaikh Oct 21 '18 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. – Bhushan Oct 22 '18 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. – Bhushan Oct 22 '18 at 6:30
  • Please refer to my answer. Hope it helps! – Sohail Shaikh Oct 22 '18 at 12:17
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, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.