14

I am using this code to get all properties for just myself (current user). But how can I change this so that I can get the same data but for all the users in SharePoint?

var oldurl = _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties";


jQuery.ajax({
    url : oldurl,
    type : "GET",
    //data: JSON.stringify(theData),
    headers: requestHeaders,
    success:function(data){
        var f = JSON.stringify(data);
        alert(JSON.stringify(data));
    },
    error:function(jqxr,errorCode,errorThrown){
        alert(jqxr.responseText);
    }
});
  • were you able to figure this out? when you get siteusers you get a lot of old users that were removed from the directory and presumably don't have access anymore too. – fei0x Oct 2 at 18:36
8

If you want to get all users of site then

_spPageContextInfo.webAbsoluteUrl + "/_api/Web/SiteUsers"

If You want to display information of User in site then

_spPageContextInfo.webAbsoluteUrl + "/_api/Web/SiteUserInfoList"

Display particular user information then

_spPageContextInfo.webAbsoluteUrl + "/_api/web/GetUserById("+UserID+")"

But in your case if you want to get all user's properties then you need to loop through and get user profile. You can also use CSOM by which you can get all user and Groups.

You can use this method to retrieve particular property of user (Reference)

SP.UserProfiles.PeopleManager.getUserProfilePropertyFor(accountName, propertyName)

You can get the idea from this Answer how to retrieve all user properties.

I got the reference from this Article

5

That can be specified by the URL that you use:

  1. Get all properties of current user:

    http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties
    
  2. Get all properties of Specific User:

    For Office 365/SharePoint Online:

    http://siteurl/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|user@domain.com'
    

    For SharePoint 2013 On-Premise:

    http://siteurl/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='domain\username'
    
  • 3
    I knew this but is there one for like getPropertiesForAllUsers? Like how can I get this without making a ton of requests? – omega Jul 6 '15 at 21:54
  • 1
    Robert, as per the msdn documentation there should be no, accountName= parameter in the GetPropertiesFor method call. msdn.microsoft.com/en-us/library/office/… But when I try calling the endpoint without one I get an error. Your way it works. Where did you learn you need to add the accountName=@v parameter? It's a little dicomforting if the official documentation is wrong. – Molotch Dec 17 '16 at 17:32

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.