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

  • 1
    try with select on end " ?$select=Id " – Marko Tica Nov 15 '19 at 16:13
  • If i add anything after the url, it tell me "The query string "loginName" is missing or invalid." – AIMEN BOULAHIA Nov 15 '19 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." – AIMEN BOULAHIA Nov 15 '19 at 16:28
1

EDIT: I saw your edit to the OP. You're looking for the email, but if you take a look at the , 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 node you underlined corresponds to the user's ID in the hidden user list. Email appears to be blank for this user, though 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.

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

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.