How to get all users in SharePoint O365 with Rest API? For example only the username.
1 Answer
Try below code:
$.ajax({
url: "https://sitecollectionurl/_api/search/query?querytext='*'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'&selectproperties='AccountName'&rowlimit='500'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
});
I am using the Search rest api with people source.
Here, i am using the search rest api with people results source to get data from search instead of directly query the user profiles as it give better performance.
If you are using this approach, then Sharepoint search has a default "rowlimit" of 500, so you need to do pagination to get more than 500 profiles as below
-
Not sure (because we abstracted all REST calls) does this endpoint work without the RequestDigest? Feb 2, 2017 at 9:26
-
This is a get request , so doesnt require request digest. So yes , it works without request digest. To test i just login to the site, open postman chrome extenstion and paste this request, works without any input required. Feb 2, 2017 at 9:30