Add Bulk Users to SharePoint Group from Excel using Rest API

This SharePoint Rest API tutorial, we will discuss, how to add bulk users to SharePoint group from Excel using the SharePoint REST API. The same Rest API code, we can use to add bulk users to the SharePoint group.

Add Bulk Users to SharePoint Group from Excel using Rest API

Recently we have a requirement to add bulk users to a SharePoint group. We have the users in one excel sheet.

In the excel sheet we have only the username like below:

  • bksahoo
  • bijay
  • sahoo like this.

And we have uploaded the excel sheet to the SharePoint SiteAssets library and then we write the code read the excel from SiteAssets library.

Below is the code to add bulk users to SharePoint groups:

<input type=button id="btnClick" value='Click Here' onclick="AddUserFromExcel();" />

<script language="javascript" type="text/javascript">
var i;
var l;
var a1;
var user;
var spGroup;

function AddUserFromExcel()
var Excel;
Excel = new ActiveXObject(“Excel.Application");
Excel.Visible = false;
var a4="Domain\\"+a1;
var clientContext = new SP.ClientContext.get_current();
var web=clientContext.get_web();
var siteGroups = clientContext.get_web().get_siteGroups();
var userCollection=spGroup.get_users();
clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
function onQuerySucceeded()
function onQueryFailed()
alert('Request failed.');

You may like following SharePoint Rest API tutorials:

This SharePoint tutorial, we learned how to add bulk users to SharePoint group using Rest API.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.