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?
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?
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
});
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
});