4

I'm using SharePoint 2013 on premises and I want to get the Id of a user to later change the Author of a listitem. I've used this url "/_api/web/siteusers(@v)?@v='{1}", but the id I get for my user is 15 and I know that my user id is 9, What am I doing bad?

2
  • do you want to get user by it's login name? Commented Sep 25, 2016 at 12:22
  • I only want the Id of the user by it's login name, then with that Id I would change the author id of an item list Commented Sep 26, 2016 at 6:35

1 Answer 1

6

There is one more way to get ID of current logged user using "_spPageContextInfo" object.

Please refer following code -->

_spPageContextInfo.userId

Reference - Understanding the _spPageContextInfo object

3
  • This will not work outside of a SharePoint page
    – Jigar
    Commented Sep 25, 2016 at 11:21
  • Yes Jigar, you are right, this object is available only on SharePoint pages. Commented Sep 25, 2016 at 12:01
  • Yes, that is not what I need, anyway thanks Rohit. Commented Sep 26, 2016 at 6:36

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.