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 Apps / The method 'UserPhotoV...
Power Apps
Answered

The method 'UserPhotoV2' has an invalid value for parameter 'id'

(0) ShareShare
ReportReport
Posted on by 41

Hi there,

 

I receive the below error:

 

 

 

Office365Users.UserPhotoV2 failed: The method 'UserPhotoV2' has an invalid value for parameter 'id'

 

 

 

 

 

I am trying to update the users Office 365 profile photo using the below

 

 

 

 

 

 

Office365Users.UpdateMyPhoto("image/jpeg", PhotoToUpload);
Set(MyPhoto,Office365Users.UserPhotoV2(MyUserId));
ClearCollect(UserPhotoCache,{UserId:MyUserId, Photo:MyPhoto,Time:Now()});UpdateContext({showLabel:true});UpdateContext({showButton:true});
UpdateContext({saveButton:false});

 

 

 

 

 

 

I'm not sure what parameter id is invalid, and it's causing the error to appear once the photo has been uploaded. I have attached a copy of the PowerApp.

 

Can anyone assist please?

 

Thankyou

Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @ChrisBrownNSFT 
    What value are you using for MyUserID?  This is not shown in your code.  It should be the user's email address.

    Example: "dsmith@yourcompany.com"

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • ChrisBrownNSFT Profile Picture
    41 on at

    @mdevaney Below is the code, it is based off of the Onboarding Tasks template canvass app...

     

    Set(MyGroup,LookUp(OutlookTasks.GetTaskGroups(),Name = "My Tasks"));
    Set(MyOutlookGroupId, MyGroup.Id);
    Set(MyProfile,Office365Users.MyProfileV2());
    Set(MyUserId,MyProfile.userPrincipalName);
    Set(MyUserDisplayName,MyProfile.displayName);
    Set(MyUserEmail,MyProfile.mail);
    Set(SelectedUser,MyUserId);
    
    ClearCollect(UserPhotoCache,
    {
     UserId:MyUserId, 
     Photo:If(Office365Users.UserPhotoMetadata(MyUserId).HasPhoto,Office365Users.UserPhotoV2(MyUserId),'default-profile'),
     Time:Now()
    });
    
    Set(
     SelectedUserProfile,
     {
     DisplayName:MyProfile.displayName,
     City:MyProfile.City,
     JobTitle:MyProfile.jobTitle,
     UserPrincipalName:MyProfile.userPrincipalName,
     GivenName:MyProfile.givenName,
     Mail:MyProfile.mail,
     Id:MyProfile.id,
     Mobile:MyProfile.mobilePhone, 
     OfficePhone:MyProfile.TelephoneNumber, 
     Department:MyProfile.Department, 
     OfficeLocation:MyProfile.officeLocation, 
     Photo: LookUp(UserPhotoCache,UserId = MyUserId).Photo
     }
    );
    
    ClearCollect(
     MyReportList,
     ForAll(
     Office365Users.DirectReports(MyUserId),
     {
     DisplayName:DisplayName,
     City:City,
     JobTitle:JobTitle,
     UserPrincipalName:UserPrincipalName,
     GivenName:GivenName,
     Mail:Mail,
     Id:Id,
     Mobile:mobilePhone, 
     OfficePhone:TelephoneNumber, 
     Department:Department, 
     OfficeLocation:OfficeLocation, 
     Photo:If(
     Not(Id in UserPhotoCache.UserId),
     Collect(UserPhotoCache,
     {
     UserId:Id, 
     Photo:If(Office365Users.UserPhotoMetadata(Id).HasPhoto,Office365Users.UserPhotoV2(Id),'default-profile'),
     Time:Now()
     }
     );
     LookUp(UserPhotoCache,UserId = Id).Photo,
     LookUp(UserPhotoCache,UserId = Id).Photo)
     }
     )
    );
    
    
    ClearCollect(
     MyPeersList,
     ForAll(
     Office365Users.DirectReports(Office365Users.Manager(MyUserId).Id),
     {
     DisplayName:DisplayName,
     City:City,
     JobTitle:JobTitle,
     UserPrincipalName:UserPrincipalName,
     GivenName:GivenName,
     Mail:Mail,
     Id:Id,
     Mobile:mobilePhone, 
     OfficePhone:TelephoneNumber, 
     Department:Department, 
     OfficeLocation:OfficeLocation,
     Photo:If(
     Not(Id in UserPhotoCache.UserId),
     Collect(
     UserPhotoCache,
     {
     UserId:Id, 
     Photo:If(Office365Users.UserPhotoMetadata(Id).HasPhoto,Office365Users.UserPhotoV2(Id),'default-profile'),
     Time:Now()
     }
     );
     LookUp(UserPhotoCache,UserId = Id).Photo,
     LookUp(UserPhotoCache,UserId = Id).Photo
     )
     }
     )
    );
    
    Set(ManagerProfile,Office365Users.Manager(MyUserId));
    
    
    
    

     

  • mdevaney Profile Picture
    29,993 Moderator on at

    @ChrisBrownNSFT 
    What does this evaluate to?

    Set(MyUserId,MyProfile.userPrincipalName);

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • ChrisBrownNSFT Profile Picture
    41 on at

    @mdevaney I'm not sure, I've just tweaked what was in the Template file. I have attached the zip if you want to take a peek and import?

  • mdevaney Profile Picture
    29,993 Moderator on at

    @ChrisBrownNSFT 

    Sorry, I don’t want to download any files.

     

    Please tell me the value resulting from that formula.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Verified answer
    ChrisBrownNSFT Profile Picture
    41 on at

    @mdevaney Thanks, i've seen where i've gone wrong with the ID and have now corrected this and it works as expected 🙂

     

    Office365Users.UpdateMyPhoto("image/jpeg", PhotoToUpload);
    Set(MyPhoto,Office365Users.UserPhotoV2(User().Email));

     

  • mdevaney Profile Picture
    29,993 Moderator on at

    @ChrisBrownNSFT 

    Yes, that's exactly why I wanted you to check your code there and using User().Email was going to be my next suggestion.  I just wasn't sure why you chose UserPrincipalName.

     

    Best of luck building your app!

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 350 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 318

#3
Mohsin Ali Profile Picture

Mohsin Ali 220

Last 30 days Overall leaderboard