Hello, I'm trying to save and load user data following THIS GUIDE.
No problem when I save them but I keep getting HTTP/1.1 400 Bad Request error every time I try to load some.
This is the guide code for saving data:
void SetUserData() { PlayFabClientAPI.UpdateUserData(new UpdateUserDataRequest() { Data = new Dictionary<string, string>() { {"Ancestor", "Arthur"}, {"Successor", "Fred"} } }, result => Debug.Log("Successfully updated user data"), error => { Debug.Log("Got error setting user data Ancestor to Arthur"); Debug.Log(error.GenerateErrorReport()); }); }
This is the guide code for loading data:
void GetUserData(string myPlayFabeId) { PlayFabClientAPI.GetUserData(new GetUserDataRequest() { PlayFabId = myPlayFabeId, Keys = null }, result => { Debug.Log("Got user data:"); if (result.Data == null || !result.Data.ContainsKey("Ancestor")) Debug.Log("No Ancestor"); else Debug.Log("Ancestor: "+result.Data["Ancestor"].Value); }, (error) => { Debug.Log("Got error retrieving user data:"); Debug.Log(error.GenerateErrorReport()); }); }
There is no clue on which value should replace "myPlayFabeId" but I'm guessing it should be the User ID from which get the data, even if there is no mention on it in the saving data code. So I tried both User ID and App ID, but I just keep getting that error.
This is how I am saving the data (it works just fine):
public static void SaveData(string p_key, string p_data) { if (!ConnectionManager.Connected) return; PlayFabClientAPI.UpdateUserData(new UpdateUserDataRequest() { Data = new Dictionary<string, string>() { {p_key, p_data} } }, result => { Debug.Log($"PlayFab Saved {p_key} = {p_data}"); }, error => { Debug.Log($"Got error setting user data {p_key} to {p_data}"); Debug.Log(error.GenerateErrorReport()); }); }
This is how I am loading the data:
public static string LoadData(string p_key) { string _result = ""; if (!ConnectionManager.Connected) { return ""; } PlayFabClientAPI.GetUserData(new GetUserDataRequest() { PlayFabId = PlayFabAPIManager.EntityID, Keys = null }, result => { //Debug.Log("Got user data:"); if (result.Data != null && result.Data.ContainsKey(p_key)) { _result = result.Data[p_key].Value; } else { Debug.Log($"No data found for {p_key} key"); } }, (error) => { Debug.Log($"Got error retrieving user data:{error.ErrorMessage}"); }); return _result; }
I think that's some problem with the GetUserData method or the GetUserDataRequest constructor because the compiler goes straight to the error handling.
,
Hello, I'm trying to save and load user data following THIS guide.
No problem for saving the data but I keep getting HTTP/1.1 400 Bad Request anytime I try to load them.
This is the suggested data lading code:
void GetUserData(string myPlayFabeId) { PlayFabClientAPI.GetUserData(new GetUserDataRequest() { PlayFabId = myPlayFabeId, Keys = null }, result => { Debug.Log("Got user data:"); if (result.Data == null || !result.Data.ContainsKey("Ancestor")) Debug.Log("No Ancestor"); else Debug.Log("Ancestor: "+result.Data["Ancestor"].Value); }, (error) => { Debug.Log("Got error retrieving user data:"); Debug.Log(error.GenerateErrorReport()); }); }
There is no clue on which value should replace "myPlayFabeId" but I'm guessing it should be the UserID from which must load the data, even if it is not specified inside the data saving code.
This is the suggested data saving code:
void SetUserData() { PlayFabClientAPI.UpdateUserData(new UpdateUserDataRequest() { Data = new Dictionary<string, string>() { {"Ancestor", "Arthur"}, {"Successor", "Fred"} } }, result => Debug.Log("Successfully updated user data"), error => { Debug.Log("Got error setting user data Ancestor to Arthur"); Debug.Log(error.GenerateErrorReport()); }); }
This is how I'm saving data:
public static void SaveData(string p_key, string p_data) { if (!ConnectionManager.Connected) return; PlayFabClientAPI.UpdateUserData(new UpdateUserDataRequest() { Data = new Dictionary<string, string>() { {p_key, p_data} } }, result => { Debug.Log($"PlayFab Saved {p_key} = {p_data}"); }, error => { Debug.Log($"Got error setting user data {p_key} to {p_data}"); Debug.Log(error.GenerateErrorReport()); }); }
This is how I'm loading them:
public static string LoadData(string p_key) { string _result = ""; if (!ConnectionManager.Connected) { return ""; } PlayFabClientAPI.GetUserData(new GetUserDataRequest() { PlayFabId = PlayFabAPIManager.EntityID, Keys = null }, result => { //Debug.Log("Got user data:"); if (result.Data != null && result.Data.ContainsKey(p_key)) { _result = result.Data[p_key].Value; } else { Debug.Log($"No data found for {p_key} key"); } }, (error) => { Debug.Log($"Got error retrieving user data: {error.ErrorMessage}"); }); return _result; }