question

aaronbuhr avatar image
aaronbuhr asked

Null result from GetPlayerProfile

Player Data
10 |1200

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

Seth Du avatar image
Seth Du answered

I cannot reproduce your issue and your code works fine in my title. The reason why you get null is the second API call doesn't run successfully. Try to add some debug codes (Result.Error.GenerateErrorReport()) in your project and double check the settings in the game manager:


10 |1200

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

aaronbuhr avatar image
aaronbuhr answered

Hello. I'm trying to get the player profile on login mostly to get player location data. However when I login the InfoResultPayload is null, and when I try GetPlayerProfile the result is null. I'm using a PlayFabId, which I've verified is correct, for the logged-in user, who has as Display Name. I've tried both leaving the ProfileConstraints as default, and using the ProfileConstraints from https://api.playfab.com/docs/tutorials/landing-players/getting-player-profiles . In the title options I've set up the Client Profile Options to allow Creation Date, Display Name, Last login time, Locations, and Origination. I've tried requesting using both the C# SDK and UE4 C++ SDK.

Is there something still I'm missing, or any suggestions to get this working? Thank you.

10 |1200

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

Marcus Nixon avatar image
Marcus Nixon answered

Hi aaronbuhr,

Can you please post a code snippet of the API calls that you are making so that I can attempt to reproduce the issue?

10 |1200

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

aaronbuhr avatar image
aaronbuhr answered

Here you are and thanks:

class Program
{
const string devApiKey = "xxxx";
const string titleId = "1234";
static readonly string[] playerCustomId = { "F0D4CC0D0F783187", "D16B8203BD326C75", "A9ED11C209C7D5C9" };
const string PlayerPlayFabId = "2F4AD14981743EC1"; static void Main(string[] args)
{
var svc = new PlayfabService();
svc.Initialize(titleId, devApiKey);
var loginResult1 = svc.LoginUser(titleId, playerCustomId[0]);
var profileResult = svc.GetPlayerProfile(PlayerPlayFabId); // profileResult comes back null
}
}
------
public class PlayfabService
{
public void Initialize(string titleId, string devApiKey)
{
PlayFabSettings.staticSettings.TitleId = titleId;
PlayFabSettings.staticSettings.DeveloperSecretKey = devApiKey;
} public PlayFab.ClientModels.LoginResult LoginUser(string titleId, string customId)
{
var request = new PlayFab.ClientModels.LoginWithCustomIDRequest
{
TitleId = titleId,
CustomId = customId,
CreateAccount = false
};
var task = PlayFabClientAPI.LoginWithCustomIDAsync(request);
PlayFabResult<PlayFab.ClientModels.LoginResult> result = task.Result;
return result.Result;
} public PlayFab.ClientModels.GetPlayerProfileResult GetPlayerProfile(string playfabId)
{
var profileRequest = new PlayFab.ClientModels.GetPlayerProfileRequest()
{
PlayFabId = playfabId,
ProfileConstraints = new PlayFab.ClientModels.PlayerProfileViewConstraints
{
ShowDisplayName = true,
ShowCreated = true,
ShowLastLogin = true
}
};
var getprofileTask = PlayFabClientAPI.GetPlayerProfileAsync(profileRequest);
PlayFabResult<PlayFab.ClientModels.GetPlayerProfileResult> profileResult = getprofileTask.Result;
return profileResult.Result;
}
}

10 |1200

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

aaronbuhr avatar image
aaronbuhr answered

Thanks for the tip about Result.Error. I was in fact getting back an error of PlayerNotInGame, "Invalid player, player has not played this title. I have a follow-on question, if I may: From reading other forum posts I recall there being a recommendation for using the location as provided by Playfab as a geolocation for matchmaking purposes. Is this correct, and if so where is that data provided? I see "Locations" in the PlayerProfileModel that is returned on login, but it looks and sounds like that will not do the job. That only returns "list of geographic locations from which the player has logged into the title", and we would need the CURRENT location that the user is logging in from, and for initial matchmaking it sounds like we would not receive any location data from Playfab. What is your recommendation, or should I make this a separate forum post? Thank you.

10 |1200

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

Marcus Nixon avatar image
Marcus Nixon answered

If you don't mind, can you please create a separate forum post for the additional issue/question you have? That way, someone else can search and find results on the same topics easier.

10 |1200

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

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.