question

software1103 avatar image
software1103 asked

How to avoid the errior that occurs on PlayFabClientAPI.UpdateUserData?

Hello, everyone.

I am experiencing some trouble with playfabclientapi.

I am gonna update the player data from client, but there are some issues.

there is my client c# code.

public void OnClickCreateRoom()
    {
        print("Connected to master.");
        RoomOptions roomOptions = new RoomOptions() { IsVisible = true, IsOpen = true, MaxPlayers = 10 };
        PhotonNetwork.CreateRoom(RoomCreate.Instance.roomName.GetComponent<TMP_InputField>().text, roomOptions, TypedLobby.Default);
        SetUserData();
    }


public void SetUserData()
    {
        PlayFabClientAPI.UpdateUserData(new UpdateUserDataRequest()
        {
            Data = new Dictionary<string, string>() {
            {"RoomName", RoomCreate.Instance.roomName.GetComponent<TMP_InputField>().text}
        }
        },
        result => Debug.Log("Successfully updated user data"),
        error =>
        {
            Debug.Log(error.GenerateErrorReport());
        });
    }

Above code, the error is performed continuously, but I don't know resolution.

/Client/UpdateUserData: Invalid input parameters
Data: The value for key RoomName was not valid JSON.
UnityEngine.Debug:Log(Object)
RoomCreator:<SetUserData>m__1(PlayFabError) (at Assets/Scripts/PhotonScripts/RoomCreator.cs:115)
PlayFab.Internal.PlayFabUnityHttp:OnResponse(String, CallRequestContainer) (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:262)
PlayFab.Internal.<Post>c__Iterator1:MoveNext() (at Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:191)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

What's the reason? Why?

I'm using Visual Studio Professional 2017.

Help me... Thanks.

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

·
Seth Du avatar image
Seth Du answered

Would you please print out

RoomCreate.Instance.roomName.GetComponent<TMP_InputField>().text

It seems there is a JSON format error there

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.

software1103 avatar image software1103 commented ·

Thanks for your advice. I have finished this.

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.