Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

UserPhotoMetaData UserID Error

Hey guys,


Sorry, I know that there are many discussion opened about this matter but I didn't understand if there is a solution or if Microsoft team is working on it.

I have tried many ways to avoid the error but without success. What is funny is that the code is working, but with this annoying error message.





Office365Users.UserPhotoMetadata failed: The method 'UserPhotoMetadata' has an invalid value for parameter 'userId'



Accepted Solutions

Hey @wagnerfraga It is frustrating but can we give it another try? 


Expression: If(!IsBlank(ThisItem.Email),If(Office365Users.UserPhotoMetadata(ThisItem.Email).HasPhoto=true,Office365Users.UserPhotoV2(ThisItem.Email),SampleImage))
Please try to use this one. There is a similar thread which resolved the error by putting a if condition around the ID and then referring to the same ID in office365 connector.
Hope this Helps!

View solution in original post

Dual Super User II
Dual Super User II

Hi @wagnerfraga 


Can you confirm what is the sharepointID that you are referring to? Office365Users.UserPhotoMetadata() expects the userid(Principal Name/ Email ID) of the user for which we want to search data for.

Please make sure that you are passing correct data inside office365 function. 
Here is an example of what I tried myself: 
In this example, I used current logged in user's email id and if you want to fetch it from Sharepoint, please use the expression:
Lookup(<<SP List>>,Name = "<Name of the User>").Email
Name/Email will be replaced by attributes in your SP list.
MicrosoftTeams-image (71).png

Hope this Helps


If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Hi @yashag2255 ,

thanks for coming back to me.


One of my tentatives was getting the user id using Office365Users.UserProfile(InfoAbout.Text).Id and I have stored it as sharepointID.


I have tried as well the code:


And I am facing the same error message.

Hey @wagnerfraga 


As per your last response, I am assuming that you are setting up a variable(email) and then referencing it in the query.
Can you please share a snippet/Screenshot of where exactly are you initializing this variable.
Also, please share the screenshot of label text that is getting displayed if you use email variable as its text property. Through this, we will get to know what exactly is getting filled in the email variable, and what is passed as the argument for office365 query.

Thanks @yashag2255 
I am getting this variable from the database.

Let me know if this screenshot helps:


I see that you are able to get the image, please click on the red cross and share the error that you are getting now.

Sure @yashag2255 , it is the same error.

Screenshot 2019-06-03 at 16.58.59.png



That's Strange! I got the same formula working in my system. Can you try out few things:
Before anything, this might be a caching issue. Can you save your app, logout of the current session and login back in a fresh browser window and check if the error still shows up? If it still does, can you try these out?
You might want to delete your current connection to O365 and create a fresh connection too. 
1) Place this expression on the Image control:
The strangest part is you are getting back the image and still getting the error.

Yes @yashag2255 , it is completly strange.

When I logout of the current session and login back in a freash browser the error vanishid, but I just click in the code and the error appear again.

I just deleted the current connection to O365 and created a fresh one, I update the code you have requested and I received a different error:

Office365Users.UserPhotoMetadata failed: { "error": { "code": "Request_BadRequest", "message": "Unrecognized query argument specified: 'userId'.", "innerError": { "request-id": "7cf2213c-6317-4215-951e-d18a2e1030ea", "date": "2019-06-04T10:43:13" } } }



I did a little research and there are few threads which see similar error with the UserPhotoMetadata connector. I tried the same code and it works fine for me. 
Looking at your latest issue, I am guessing that only possible reason is the improper connection to office365, it is not recognizing userid which is a required attribute. So, please try to recreate the connection and type your command again.
Hope this Helps!

Helpful resources

PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,962)