web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Unable to fetch user i...
Power Automate
Answered

Unable to fetch user id after passing obtained access token of my sharepoint app in Microsoft flow

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Went through these tutorials to assign item-level permissions using Flows:

https://noellawlor.wordpress.com/2018/01/18/setting-sharepoint-item-list-permissions-with-flow/

and a follw-up to 

https://powerusers.microsoft.com/t5/Using-Flows/Item-Level-Permissions-not-setting-in-sharepoint-online/m-p/261578#M6250

 

I am unauthorized to fetch the user ID in flow. 

 

Here's what I did:

usernameclaim.PNG

 

get_user_id.PNG

 

After running the workflow:

unauthorized.PNG

Categories:
I have the same question (0)
  • MattWeston365 Profile Picture
    1,701 on at

    Have you tried running the call within Postman to see if you get the same result?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Postman says

    {
    "odata.error": {
    "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
    "message": {
    "lang": "en-US",
    "value": "The query string \"loginName\" is missing or invalid."
    }
    }
    }

     

    What I read from Microsoft Flow docs, to get user id by REST API in flow, you have to pass your login name in this URL format:

    https://<sharepoint-sitename>/_api/web/siteusers(@v)?@v=’<login-name>'

    and various examples have used 'CreatedBy Claims' to get the <login-name>

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Here is one more good example following my question:

    get_user_id.PNG

     

    I replaced '' with %27 and am passing the encodeURIcomponent(variables['email']) value as a request parameter and still says 'Unauthorized'. I did the same thing in Postman and it fetched me the result. I don't what's going wrong. No way to debug and no way to see what's going wrong. Sharepoint Online is such a frustrating creation of Microsoft. I have been stuck into Item-Level permissions for 2 weeks and still 25% success. 

     

    Also to let you know that I tried encoding UserClaims and passed the same way as I have asked in the original question but it's still unautorized.

  • Verified answer
    MattWeston365 Profile Picture
    1,701 on at

    Hi @Anonymous have you considered using the builtin "Sent HTTP Request to SharePoint" action? That way you won't have to worry about the oauth elements, you just need to get your REST call right. Happy to provide guidance on that action if you need any help.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I didn't feel the need to use HTTP connector and try the Oauth steps. "Send HTTP Request to Sharepoint" does all that without prompting you for access tokens.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard