1

I'd like to get users from a certain Department. I've been looking for a while and haven't found whether it's possible or not ... I saw the http://spsite/_api/web/siteusers URL but it doesn't give us the Department.

3
  • By department you mean the group?
    – Akhoy
    Jul 29, 2015 at 12:29
  • @uberz91 there's a user profile property Department
    – moe
    Jul 29, 2015 at 12:30
  • Use search REST API to get the users , Department should have an OOTB maanaged property to appply filter. Jul 29, 2015 at 13:17

1 Answer 1

2

You can query the user information list to get all the users for a site. Use: http://siteUrl/_api/web/lists/getbytitle('User Information List')/items?$filter=Department eq 'Value'. This will return all the users with the department Value for that particular site.

8
  • This returns items from a list where the column Department equals to the Value. As long as there's not an OOTB SharePoint list including all users of the environment, this is useless.
    – moe
    Jul 30, 2015 at 5:27
  • What do you mean? User Information List is a hidden list available for every SharePoint site. Its how users and groups are managed in SharePoint.
    – Akhoy
    Jul 30, 2015 at 5:28
  • Ah, you're correct! Wasn't aware of the hidden list.
    – moe
    Jul 30, 2015 at 5:36
  • @uberz91: User Information List contains information of only users which have logged in at least one time, user added in any sharepoint groups or user used in any User Field. So In Short, it will not contains all the users and that's why it is not appropriate way to get all the users.You can check this by creating one blank site collection and first check UserInformationList without doing anything in the site. You will get only one entry on that list that is site collection administrator Jul 30, 2015 at 9:00
  • 1
    Fantastic. I've tested it and it works. However, I had a little issue since I have French names on my lists, so I had to find another URL to get the list results. http://siteUrl/_api/web/SiteUserInfoList/items?$filter=Department eq 'Value' Thanks a lot !!
    – Chris23
    Jul 30, 2015 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.