Showing results for 
Search instead for 
Did you mean: 
Advocate III
Advocate III

Office365Users.UserPhotoV2 failed error Frequently


Since last 3 days I am getting error in two methods of Office365Users connectors, 1) UserPhotoV2(), 2) UserPhotoMetadata().

This is a employee directory application, List is shown in gallery with photo.


Error occurs in both Office365Users.UserPhotoV2 and deprecated Office365Users.UserPhoto formulas. 




Office365Users.UserPhotoV2 failed: {
  "error": {
    "code": 500,
    "source": "",
    "clientRequestId": "968019ba-7a0b-4c34-bd0b-2c41b3917815",
    "message": "BadGateway",
    "innerError": {
      "error": {
        "code": "ErrorInternalServerError",
        "message": "The email address \"Ankit\" isn't correct. Please use this format: user name, the @ sign, followed by the domain name. For example, or REST APIs for this mailbox are currently in preview. You can find more information about the preview REST APIs at",
        "innerError": {
          "date": "2020-08-12T07:27:48",
          "request-id": "9025ceca-a27f-4a6c-96e5-90967471c4c0"



Gallery Image formula


If(!IsBlank(ThisItem.Id), Office365Users.UserPhotoV2(ThisItem.UserPrincipalName))



Also tested with


If(!IsBlank(ThisItem.Id), Office365Users.UserPhotoV2(ThisItem.Id))
If(!IsBlank(ThisItem.Id), Office365Users.UserPhotoV2(ThisItem.Mail))



Error is also coming in Office365Users.UserPhotoMetadata() formula


Office365Users.UserPhotoMetadata failed: { "error": { "code": 500, "source": "", "clientRequestId": "7df34e0f-8b68-40dc-b942-2810712420ab", "message": "BadGateway", "innerError": { "error": { "code": "ErrorInternalServerError", "message": "The email address \"Ankit\" isn't correct. Please use this format: user name, the @ sign, followed by the domain name. For example, or tony...



All above mentioned error comes in all end users including makers.

Super User
Super User

What if you try:

    Office365Users.UserPhotoV2( Substitute(Substitute(ThisItem.Mail , Char(34), ""), "\", ""))


If it works, consider it as a temporary solution.

Community Support
Community Support

Hi @AnkitShah55 ,

Could you tell me the formula in your gallery's Items?

It seems like your email is :


If so, this email address format is not supported.

I believe that you use wrong email address in   Office365Users.UserPhotoV2 function.

You could enter the email address in azure admin center to check whether this email address exists in your talent.

I've made a similar test and I could get right image by using Office365Users.UserPhotoV2 function.

So I so not think this connector has any problem.





Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yutliu-msft , @Alex_10 ,


This is gallery data

Filter(Office365Users.SearchUserV2({top:2000, searchTerm:If(Len(SearchInput.Text)>0, SearchInput.Text, User().Email)}).value, AccountEnabled=true)

Where SearchInput is simple Text Input field. If that field is empty than simply current user email is passed in SearchUserV2 as per above formula.


This is Image formula of gallery 


Please note that in error text I mentioned in earlier post, my email is incorrect. 

Incorrect: Ankit\
Correct: is one of the email domain of my organisation. 

During testing with other 5-7 users of my org, found that all users are getting same problem with incorrect email in error text.

This never occured in past.

What if you try:

Filter(Office365Users.SearchUserV2({top:2000, searchTerm:If(Len(SearchInput.Text)>0, SearchInput.Text, Office365Users.MyProfileV2().mail)}).value, AccountEnabled=true).

If it works then in this case the problem is that user's Powerapps account email is not the same as Office365 account email.

Advocate II
Advocate II

You may have already resolved this, but just in case -- I found this here: .  My situation is that I have old users that no longer exist in AD, but I don't want to lose those records. So I use a boolean to determine if they exist first. AcctEnabled is a boolean:  IsEmpty(Office365Users.SearchUserV2({searchTerm:emailtext.Text}).value.Id). Then for the image:  If(Not(AcctEnabled),If(!IsBlank(Office365Users.UserPhotoV2(Label1.Text)),Office365Users.UserPhotoV2(Label1.Text)),'person icon')

Super User
Super User

This formula I use to suppress all errors for example if a user has left the company, this is currently working perfectly.

!IsBlank(ThisItem.'Requested By'.Email),
IfError(Office365Users.UserPhotoMetadata(ThisItem.'Requested By'.Email).HasPhoto, ""),
IfError(Office365Users.UserPhotoV2(ThisItem.'Requested By'.Email), ""),

This just helped me. Thank you!

Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,294)