Skip to main content

How to get all site users of SharePoint using REST API?


Get all users of SharePoint site using REST API:

These users and its data are required to update people field of a SharePoint list.

By using below snippet code we can able to get details of a user of SharePoint site.

    var webURL = _spPageContextInfo.webAbsoluteUrl+"/_api/Web/SiteUsers";

        $.ajax({

          url: customFieldURL,

          method: "GET",

          headers: {

            "Accept": "application/json; odata=verbose"

          },

          success: function (data) {

           console.log(data);

            data.d.results.forEach(function(cm){

                    console.log(cm.Title+" - "+cm.Email+" - "+cm.Id);

            });

          },

          error: function (error) {

            // error handler code goes here

            console.log(error)

          }

        });



 

Comments