question

Rizwan Babar avatar image
Rizwan Babar asked

409 Conflict on UpdateUserData

Hi. I am getting 409 conflict and there are just 2 API calls. This is my current code:

public void Login()
    {
        string customId = "";
        if (PlayerPrefs.HasKey("unique_identifier"))
        {
            customId = PlayerPrefs.GetString("unique_identifier");
        }
        else
        {
            customId = System.Guid.NewGuid().ToString();
            PlayerPrefs.SetString("unique_identifier", customId);
        }


        Debug.Log("UNIQUE IDENTIFIER: " + customId);


        LoginWithCustomIDRequest request = new LoginWithCustomIDRequest()
        {
            TitleId = PlayFabSettings.TitleId,
            CreateAccount = true,
            CustomId = customId //SystemInfo.deviceUniqueIdentifier
        };


        PlayFabClientAPI.LoginWithCustomID(request, (result) =>
        {
            PlayFabId = result.PlayFabId;
            Debug.Log("Got PlayFabID: " + PlayFabId);


            Dictionary<string, string> data = new Dictionary<string, string>();


            if (result.NewlyCreated)
            {
                Debug.Log("(new account)");
                setInitNewAccountData(false);


                string name = result.PlayFabId;
                name = "Guest";
                for (int i = 0; i < 6; i++)
                {
                    name += UnityEngine.Random.Range(0, 9);
                }


                data.Add("PlayerName", name);
                //addCoinsRequest(StaticStrings.initCoinsCount);
            }
            else
            {
                CheckIfFirstTitleLogin(PlayFabId, false);
                Debug.Log("(existing account)");
            }




            data.Add("LoggedType", "Guest");


            GameManager.Instance.myPlayerData.UpdateUserData(data);


            GameManager.Instance.nameMy = name;


            PlayerPrefs.SetString("LoggedType", "Guest");
            PlayerPrefs.Save();


            fbManager.showLoadingCanvas();




            GetPhotonToken();


        },
            (error) =>
            {
                Debug.Log("Error logging in player with custom ID:");
                Debug.Log(error.ErrorMessage);
                GameManager.Instance.connectionLost.showDialog();
            });
    } 

setInitNewAccountData(false) and GameManager.Instance.myPlayerData.UpdateUserData(data) call UpdateUserData and they are only 2 API calls being but still getting 409 conflict error. I have exactly same code on another project of mine and it works perfectly on that project. Any solution?

Player Datadata
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

·
Made Wang avatar image
Made Wang answered

In your code, when logging in as a new user, UpdateUserData will be called twice in the same callback. They are performed at the same time, which is not allowed.

You need to start the next call in the callback of one call.

You can check these threads to learn more:

409 Conflict on UpdateUserData - Playfab Community

409 Conflict when calling GetContentUploadUrl - Playfab Community

2 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.

Rizwan Babar avatar image Rizwan Babar commented ·

Yeah I figured that out but one of the threads I saw yesterday, someone from PlayFab team also mentioned that two API calls shouldn't create a conflict.

Also why would exactly same code work without any issue in my other projects if this code is to create a conflict?

0 Likes 0 ·
Made Wang avatar image Made Wang Rizwan Babar commented ·

In your code, this error will be reported when logging in as a new user, and logging in as an existing user is successful.

0 Likes 0 ·

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.