question

mhss5458 avatar image
mhss5458 asked

SetTitleData does not save anything in playfab

Hi, I have a question about setting up the title data. As far as I know there are few ways to save title data

1. PlayFabClientAPI.UpdateUserData

2. PlayFabServerAPI.SetTitleData()

I really don't know what the differences between two, and I need to add new title data everytime, but UpdateUserData doesn't allow that.

I tried to use SetTitleData, but it actually does not save to my PlayFab account, but in editor extension only...

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

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

For the clarification, the Client API UpdateUserData is designed to update the player data that belongs to the title player account, you can view the documentation - Player Data - PlayFab | Microsoft Docs for more information about it. And the Server API SetTitleData is designed to update the title data. Please check the documentation - Title Data quickstart - PlayFab | Microsoft Docs for more information about the title data. Since the Title Data is designed to store the title configurations that belongs to the management data, if players can update it, there will be security issues. So there is no Client API SetTitleData. And, also please note, all Server APIs can’t be accessed by clients. They can only be accessed by the server-sides.

Could you please clarify what is your detailed requirement? And which development platform you are using? Do you mean you called the Client API UpdateUserData, and itreturned the error to you? If so, could you please provide your current sample code and the detailed error messages?

Besides, you can also refer to the sample code to update the user data in this section - Add a methods to set the player data and retrieve the player data for more information.

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.

mhss5458 avatar image mhss5458 commented ·

Thank you so much for clarification. It helps me to understand the issue. My problem is, I would like to save the user data anytime I want so that, it does not replace the existing one. It means that, I cannot set the size of 'key' and 'value' at the beginning.
For example,

//timeStamp is string, and get from server (timeStamp = result.Time.ToString();)

public void SaveData()
    {
        PlayFabClientAPI.UpdateUserData(new PlayFab.ClientModels.UpdateUserDataRequest()
        {
            Data = new Dictionary<string, string>()
            {
                { timeStamp, JsonUtility.ToJson(playerData)}
            }
        }, SuccessSaveData, FailSaveData);
    }

If I use this function, I can only update the user data, but cannot append the data everytime I call this funciton. Is there any other way to keep adding the key and values instead of updating?

0 Likes 0 ·
mhss5458 avatar image mhss5458 mhss5458 commented ·

Actually, I just figure out that key name is different, it automatically adds the entity. Thank you!

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.