Hi, i can't get player data on cloud script. Thanks for help.
PlayerCombinedInfo part here.
var GetPlayerCombinedInfoRequest = { "PlayFabId": currentPlayerId, "InfoRequestParameters" : { "GetUserAccountInfo": true, "GetUserInventory": true, "GetUserVirtualCurrency": true, "GetUserData": false, "GetUserReadOnlyData": true, "GetCharacterInventories": false, "GetCharacterList": false, "GetTitleData": false, "GetPlayerStatistics": true } }; var GetPlayerCombinedInfoResult = server.GetPlayerCombinedInfo(GetPlayerCombinedInfoRequest); return JSON.stringify(GetPlayerCombinedInfoResult.InfoResultPayload);
ExecuteCloudScript on Client,
ExecuteCloudScriptRequest request = new ExecuteCloudScriptRequest { FunctionName = GlobalStrings.CloudFunction_GetInitData }; PlayFabClientAPI.ExecuteCloudScript(request, GetInitData_Success, ErrorControl);
Result on Client,
GetPlayerCombinedInfoResultPayload playerData = new GetPlayerCombinedInfoResultPayload (); playerData = PlayFab.Json.JsonWrapper.DeserializeObject<GetPlayerCombinedInfoResultPayload>(result.FunctionResult.ToString()); Debug.Log(playerData.AccountInfo.PlayFabId);
I know, this my fault but where do i make mistakes? Deserialize is wrong ? Please show me the correct way, thanks.
There is log,
InvalidCastException: Value is not a convertible object: System.String to System.Nullable`1[[PlayFab.ClientModels.UserOrigination, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] System.Convert.ToType (System.Object value, System.Type conversionType, IFormatProvider provider, Boolean try_target_to_type) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Convert.cs:2941) System.String.System.IConvertible.ToType (System.Type targetType, IFormatProvider provider) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:2420) System.Convert.ToType (System.Object value, System.Type conversionType, IFormatProvider provider, Boolean try_target_to_type) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Convert.cs:2937) System.Convert.ChangeType (System.Object value, System.Type conversionType, IFormatProvider provider) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Convert.cs:2511) PlayFab.Json.PocoJsonSerializerStrategy.DeserializeObject (System.Object value, System.Type type) (at Assets/PlayFabSdk/Shared/Internal/SimpleJson.cs:1416) PlayFab.Json.PocoJsonSerializerStrategy.DeserializeObject (System.Object value, System.Type type) (at Assets/PlayFabSdk/Shared/Internal/SimpleJson.cs:1482) PlayFab.Json.PocoJsonSerializerStrategy.DeserializeObject (System.Object value, System.Type type) (at Assets/PlayFabSdk/Shared/Internal/SimpleJson.cs:1482) PlayFab.Json.PocoJsonSerializerStrategy.DeserializeObject (System.Object value, System.Type type) (at Assets/PlayFabSdk/Shared/Internal/SimpleJson.cs:1482) PlayFab.Json.PlayFabSimpleJson.DeserializeObject (System.String json, System.Type type, IJsonSerializerStrategy jsonSerializerStrategy) (at Assets/PlayFabSdk/Shared/Internal/SimpleJson.cs:603) PlayFab.Json.PlayFabSimpleJson.DeserializeObject[GetPlayerCombinedInfoResultPayload] (System.String json) (at Assets/PlayFabSdk/Shared/Internal/SimpleJson.cs:618) PlayFab.Json.SimpleJsonInstance.DeserializeObject[GetPlayerCombinedInfoResultPayload] (System.String json) (at Assets/PlayFabSdk/Shared/Internal/ISerializer.cs:61) PlayFab.Json.JsonWrapper.DeserializeObject[GetPlayerCombinedInfoResultPayload] (System.String json) (at Assets/PlayFabSdk/Shared/Internal/ISerializer.cs:33) TriflesGames.GeniusGame.DataManager.GetInitData_Success (PlayFab.ClientModels.ExecuteCloudScriptResult result) (at Assets/#TriflesGames#/Scripts/Managers/Playfab/Data/DataManager.cs:188) PlayFab.Internal.PlayFabHttp+<MakeApiCall>c__AnonStorey0`1[PlayFab.ClientModels.ExecuteCloudScriptResult].<>m__1 () (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabHTTP.cs:170) PlayFab.Internal.PlayFabWww+<MakeApiCall>c__AnonStorey1.<>m__0 (System.String response) (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabWWW.cs:126) UnityEngine.Debug:LogException(Exception) PlayFab.Internal.<MakeApiCall>c__AnonStorey1:<>m__0(String) (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabWWW.cs:130) PlayFab.Internal.<Post>c__Iterator0:MoveNext() (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabWWW.cs:200) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)