question

Noor Khawaja avatar image
Noor Khawaja asked

GetProfiles call from Azure Function comes back empty

I need to fetch profiles of a player's friends with GetProfiles in my Azure Function. But the profiles list comes back empty. Please see the source code sequence below. What am I doing wrong here?

// Azure Function code

PlayFabSettings.staticSettings.TitleId = "<my title id>";<br>PlayFabSettings.staticSettings.DeveloperSecretKey  = "<my dev secret key>";

// Call GetEntityToken
var requestEntityToken = new PlayFab.AuthenticationModels.GetEntityTokenRequest();
var resultEntityToken = await PlayFab.PlayFabAuthenticationAPI.GetEntityTokenAsync(requestEntityToken); 
// successfully returns the entity token in result

// Call GetFriendsList
var getFriendsT = await Player.GetFriendsList(playerId);
var friends = getFriendsT.Result.Friends;
// successfully returns list of friends

// Prepare Entities for GetProfilesRequest
List<PlayFab.ProfilesModels.EntityKey> entities = new List<PlayFab.ProfilesModels.EntityKey>();
foreach (var friend in friends)
{
    entities.Add(
        new PlayFab.ProfilesModels.EntityKey() 
        { 
        Id = friend.FriendPlayFabId,
        Type = "title_player_account"
        }
    );
}

// Call GetProfiles
var request = new GetEntityProfilesRequest();
request.AuthenticationContext = new PlayFabAuthenticationContext();
request.AuthenticationContext.EntityToken = resultEntityToken.Result.EntityToken;
request.Entities = entities;
var resultProfiles = await PlayFabProfilesAPI.GetProfilesAsync(request);

// PROBLEM: resultProfiles.Result.Profiles list is empty!


entities
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

·
Gosen Gao avatar image
Gosen Gao answered

API GetProfiles needs entities with a type of “title_player_account”, while the FriendPlayFabId obtained from GetFriendsList is “master_player_account”, so the response is empty. To get the player profile, you can add a ProfileConstraints parameter when you call API GetFriendsList to get some player profile directly.

4 comments
10 |1200

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

Noor Khawaja avatar image Noor Khawaja commented ·

Thanks for your reply.

My purpose of calling GetProfiles on player's friends was to fetch all title player account Objects from the player's friends in one shot. My player's Object contains some custom piece of information such as DP avatar background color. (basically a json)

What would be the best way to go about this? Where should I store this custom data for a player and how can I retrieve it in a batch for all of the player's friends?

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao Noor Khawaja commented ·

You can call API SetFriendTags to add the new friend's title player account to the Tags when the player adds a friend. Then you can get all friends’ title player account in their Tags when you call API GetFriendsList and use them to call API GetProfiles to get the objects.

0 Likes 0 ·
Noor Khawaja avatar image Noor Khawaja Gosen Gao commented ·

Brilliant! Thank you. It works from the Azure function!

0 Likes 0 ·
Show more comments

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.