question

Dirtcube Admin avatar image
Dirtcube Admin asked

GetFriendsList alway returns null for FriendInfo AvatarUrl,GetFriendsList always returns null for FriendInfo AvatarUrl

I am trying to call GetFriendsList in the Unity SDK. I set ShowAvatarUrl to true in ProfileConstraints of GetFriendsListRequest, but it still returns null. DisplayName works fine. Here is a sample of my code -

 GetFriendsListRequest request = new GetFriendsListRequest();
         request.ProfileConstraints = new PlayerProfileViewConstraints();
         request.ProfileConstraints.ShowAvatarUrl = true;
    
         PlayFab.PlayFabClientAPI.GetFriendsList(request, (GetFriendsListResult result) =>
         {
             if (result.Friends == null)
                 Debug.LogError("Retrieved null friends");
             else
             {
                 foreach (PlayFab.ClientModels.FriendInfo friend in result.Friends)
                 {
                     Debug.Log($"Friend: {friend.Profile.DisplayName} - tag {friend.Tags?[0] ?? ""} - AvatarUrl = {friend.Profile.AvatarUrl}");
                 }
             }
    
         }, (PlayFab.PlayFabError error) =>
         {
             Debug.LogError(error.ErrorMessage);
         });

,I am trying to retrieve friends list, and in the response friend.Profile.AvatarUrl is always null even after setting ProfileConstraints.ShowAvatarUrl to true. Here is my sample code for the request -

 GetFriendsListRequest request = new GetFriendsListRequest();
         request.ProfileConstraints = new PlayerProfileViewConstraints();
         request.ProfileConstraints.ShowAvatarUrl = true;
    
         PlayFab.PlayFabClientAPI.GetFriendsList(request, (GetFriendsListResult result) =>
         {
             if (result.Friends == null)
                 Debug.LogError("Retrieved null friends");
             else
             {
                 foreach (PlayFab.ClientModels.FriendInfo friend in result.Friends)
                 {
                     Debug.Log($"Friend: {friend.Profile.DisplayName} - tag {friend.Tags?[0] ?? ""} - AvatarUrl = {friend.Profile.AvatarUrl}");
                 }
             }
    
         }, (PlayFab.PlayFabError error) =>
         {
             Debug.LogError(error.ErrorMessage);
         });
Friends
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Xiao Zha avatar image
Xiao Zha answered

Your code is correct, you probably need to navigate to [Title settings]->[Client Profile Options] to tick the checkbox for Avatar URL, then your code should work fine. Please let me know if the problem persists.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dirtcube Admin avatar image Dirtcube Admin commented ·

Ohhh! Thank you!! This worked :)

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.