0

I am planning to get a user property (any information like email, id, title ... etc) using API REST,

https://m365x873105.sharepoint.com/sites/BBS-support/_api/web/siteusers(@v)?@v='c:0t.c|tenant|f5890ec2-77a7-4522-ac2b-ca9404278be6'

This request will return to me all the information of the choosed user,

enter image description here

but i want to get only his email.

I will explain more here, all of you agree with me that both of this requests give us the same result

.../_api/Web/GetUserById(25)/email

and this

..._api/web/siteusers(@v)?@v='c:0t.c|tenant|f5890ec2-77a7-4522-ac2b-ca9404278be6'

right? the first one get the user using his id, the second using the loginName, well for the first one if i would just to get the email, it is enough to just add /email and we'll get only the email, but for the second one it won't work, it return an error The query string "loginName" is missing or invalid., if we analyse it, i can only understand that the query string consider everything after the end-quote ' is related to the loginName, which it's not the case ! Thanks

3
  • 1
    try with select on end " ?$select=Id "
    – Marko Tica
    Commented Nov 15, 2019 at 16:13
  • If i add anything after the url, it tell me "The query string "loginName" is missing or invalid." Commented Nov 15, 2019 at 16:25
  • let me tell you this, let's say i already have the id, i will perform using this request: .../_api/Web/GetUserById(25) if i want to get a certain properties (for example the id or the email) i will just add '/id' or 'email' and it will return to me what i want, but i add this 2 last to the first one, it will return that the query string "loginName" is missing or invalid." Commented Nov 15, 2019 at 16:28

1 Answer 1

1

EDIT: I saw your edit to the OP. You're looking for the email, but if you take a look at the <d:PrincipalType>, its value is 4, which corresponds to a Security Group. Security Groups in AD don't always have email addresses, so I assume that in your example, the principal that you're looking at just doesn't have an email address.

See here: https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/ee541430(v=office.15)


By ID, what exactly are you looking for? The <d:Id> node you underlined corresponds to the user's ID in the hidden user list. Email appears to be blank for this user, though <d:Email> is where you would see their email address if it was set in SharePoint's User Profile Service.

If you're trying to code something to get the ID, you'll first need to determine which of the ID nodes you need, and then load the XML output of the REST call into an XML object and traverse the XML to get to that node.

3
  • even it's blank, what should add to this request in order to get only the email, or the title for example (any propriety) Commented Nov 15, 2019 at 19:31
  • check again the question, i just edit it to clarify more my issue Commented Nov 15, 2019 at 19:39
  • I've updated my answer, see above... Commented Nov 17, 2019 at 1:12

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.