cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AnkitShah55
Advocate III
Advocate III

Office365Users.UserPhotoV2 failed error Frequently

Hello,

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": "india-001.azure-apim.net",
    "clientRequestId": "968019ba-7a0b-4c34-bd0b-2c41b3917815",
    "message": "BadGateway",
    "innerError": {
      "error": {
        "code": "ErrorInternalServerError",
        "message": "The email address \"Ankit Shah@larsentoubro.com\" isn't correct. Please use this format: user name, the @ sign, followed by the domain name. For example, tonysmith@contoso.com or tony.smith@contoso.com. REST APIs for this mailbox are currently in preview. You can find more information about the preview REST APIs at https://dev.outlook.com/.",
        "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": "india-001.azure-apim.net", "clientRequestId": "7df34e0f-8b68-40dc-b942-2810712420ab", "message": "BadGateway", "innerError": { "error": { "code": "ErrorInternalServerError", "message": "The email address \"Ankit Shah@larsentoubro.com\" isn't correct. Please use this format: user name, the @ sign, followed by the domain name. For example, tonysmith@contoso.com or tony...

 

 

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

7 REPLIES 7
Alex_10
Super User
Super User

What if you try:
If(!IsBlank(ThisItem.Id),

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

)

If it works, consider it as a temporary solution.

v-yutliu-msft
Community Support
Community Support

Hi @AnkitShah55 ,

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

It seems like your email is :

Ankit Shah@larsentoubro.com\

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.

817.PNG

 

 

 

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 

If(!IsBlank(ThisItem.Mail),If(Office365Users.UserPhotoMetadata(ThisItem.Id).HasPhoto=true,Office365Users.UserPhotoV2(ThisItem.Id)))

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

Incorrect: Ankit Shah@larsentoubro.com\
Correct: ankitm.shah@lntmhps.com
lntmhps.com 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.

srose
Advocate II
Advocate II

You may have already resolved this, but just in case -- I found this here: https://thepoweraddict.com/office365users-connector-get-rid-of-this-warning/ .  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')

JimmyWork
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.

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

 

https://powerusers.microsoft.com/t5/Building-Power-Apps/UserPhotoMetaData-When-user-leaves-the-compa...

This just helped me. Thank you!

Helpful resources

Announcements
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)