Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

Get user profile fails with odd NotFound error even though input is valid UPN

Posted on 23 Nov 2024 18:15:15 by 4
Hello, we have a flow where the Get User Profile suddenly stopped working for some users.
To investigate the issue I created a small flow that shows the minimum needed for the issue. Here I have an action that searches for a UPN and then uses the returned user to try and get using the "Get User Profile (V2)".
I have tried with different users and it seems to work for some, and not for others.
Here is what happens:
  1. I trigger the flow manually
  2. A search is performed with the provided UPN, 1 matching user is found
  3. Get user profile (V2) is called with the "UserPrincipalName" from the "Search for users (V2)" but fails to find any users and returns "NotFound"
 
Expected behavior: If I try to use the action "Get user profile" with a UPN that I just read from the action "Search for users" I expect the other action to find the same user.
 
Added context that might be interesting:
If I try to hardcode a UPN that doesn't exist in the Get user profile, I get a different error from when I enter the known UPN from the search for user step. And with some UPNs, it works with the Get user profile.
 
This is the output I get with the malfunctioning user:
{
"error": {
"code": "-1, Microsoft.SharePoint.Client.ResourceNotFoundException",
"message": "Exception of type 'Microsoft.SharePoint.Client.ResourceNotFoundException' was thrown.",
"innerError": {
"date": "2024-11-23T18:06:39",
"request-id": "8e34f65a-939d-43de-986f-ce8c5b61a162",
"client-request-id": "8e34f65a-939d-43de-986f-ce8c5b61a162"
}
}
}
 
And this is the error I get when entering a known-nonexistent UPN:
{
"error": {
"code": "ResourceNotFound",
"message": "User not found",
"innerError": {
"date": "2024-11-23T18:12:20",
"request-id": "e821a1b7-d447-44b7-bb26-65f7f775c9b4",
"client-request-id": "e821a1b7-d447-44b7-bb26-65f7f775c9b4"
}
}
}
 
Hoping that I might be able to get some support from this community with what it is that I'm doing wrong. Thanks in advance 😊
  • Expiscornovus Profile Picture
    Expiscornovus 30,623 on 25 Nov 2024 at 20:28:04
    Get user profile fails with odd NotFound error even though input is valid UPN
     
    Thanks for sharing your tests. 
     
    Can you inspect the search for users actions outputs. What do you see in the mail property and UserPrincipalName property of the 'magical' user? Are those values different?
     
    In my example the values of those two properties were different for my external user test case. That's why I thought this was related to the fact it was an external user, that might not be the case on second thought 😅
  • Fabian-Pride Profile Picture
    Fabian-Pride 4 on 25 Nov 2024 at 20:02:10
    Get user profile fails with odd NotFound error even though input is valid UPN
    Hello @Expiscornovus, and thanks for your reply!
    That's such a great suggestion. Unfortunately the account I'm trying to find isn't an external account. The account was created by another power automate flow, and it's a flow I've been using for almost a year now with great success until now.
     
    Your reply did get me very curious. Inspired by your reply I tried re-running my flow and searched for a known external user (guest user).
    To my surprise, it worked :O
    Maybe guest and external users are different, I don't know.
     
     
    But I know that this seemed to have worked, while my "magical" user still isn't working :/
     
    When you got your "not found" error while searching for an external user, did you get the response with: "code": "ResourceNotFound" (as I got when searching for a known not-existing user) or the response "code": "-1, Microsoft.SharePoint.Client.ResourceNotFoundException", similar to what I'm getting with my newer user.
     
    Some context regarding my "new user". It was created on the evening on the 23rd (more than 48 hours ago). It was created using the Power Automate action "Create User". The call to "Create User" worked without an issue. This same Power Automate flow that creates users are usually executed about twice each week, and this is the first user we've had issues with.
     
    I really appreciated your previous reply and hope that you (or anyone else) might have any more ideas. Thanks in advance!
  • Expiscornovus Profile Picture
    Expiscornovus 30,623 on 24 Nov 2024 at 17:30:02
    Get user profile fails with odd NotFound error even though input is valid UPN
    A user can exist without a profile. Are these by any change external users?
     
    The Search for users searches for your keywords in the display name, given name, surname, mail, mail nickname and user principal name fields.
     
    So, it is possible it found a match in one of the other fields as well. In case of an external user it would find a match based on the mail field, but no profile would be found in the Get user Profile (v2) because it is an external user.
     
    Below is an example which demonstrates this
     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,246

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,884

Leaderboard