luis avatar image
luis asked

How can i StoreData in the titleData with json Object?

Hi Every One,I am new with playfab and I am trying to save data in the database of playfab (titledata) but it has been hard to understand the documentation, I want to use a serialized json object to store my data, but I have not found a way to do it, I would really appreciate it if Can somebody help me. I leave some captures of the class (what would be an entity or collection) and how i am serialized it. i Dont know what method of the API use.

Title Datadata
captura.png (24.5 KiB)
captura2.png (4.2 KiB)
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.

Thamas avatar image Thamas commented ·

Anyone still actively using this forum? am curious if i were to use this call 2 or 3 times a day, over 16-24 tablets would be too much traffic? I am referring to the Server API Calls. Would like to use the server to store data because its a small app for my business not a game. This data should be accessible from any tablet if logged in to the correct login, this is why i would like it server side not client side.

0 Likes 0 ·

1 Answer

Seth Du avatar image
Seth Du answered

Because I notice that you are using Unity Engine, please import these for convenience:

using PlayFab;
using PlayFab.ClientModels;

I will provide a sample here, and be aware that you can only use admin API and server API to upload title data.

Usuario myUsuario = new Usuario() { usuario = "testtest", /*....initialize your instance*/};
string myJsonString = JsonUtility.ToJson(myUsuario);
	new PlayFab.ServerModels.SetTitleDataRequest {
		Key= "Usuario",
		Value= myJsonString 
	Onsuccess=> {},
	Onfail=> {Onfail.GenerateErrorReport();} 

So in the game manager you will get a title data entry with key set as “Usuario” and value set as “{"usuario":" testtest "……}”

BTW, if you trying to get title data, you are able to use client API,

// after you login successfully
	newGetTitleDataRequest {
		Keys = newList<string> { "YourDataKey" } 
	OnSuccess => 
		var yourObject = JsonUtility.FromJson<Usuario>(OnSuccess.Data["YourDataKey"]); 
	OnFail => { });
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

And just to make sure there's no confusion - you should only ever be updating Title Data from your development tools. Title Data should never be updated as a result of a player action, as it is a sharded and cached resource not intended for high frequency updates.

0 Likes 0 ·
luis avatar image luis brendan commented ·

What kind of development tools are you recommend, i mean, if the way to store json objects are like he explain me before, what can other way can i use?

0 Likes 0 ·
luis avatar image luis commented ·

Thanl you!
I have another question related to your answer, that I should call api to use PlayFabServerAPI, because with PlayFab.ClientModels I can not use PlayFabServerAPI.

0 Likes 0 ·
luis avatar image luis commented ·

I realized that i have to activate the server model in the settings of play fab, my bad sorry. Thank you BTW.

0 Likes 0 ·
captura.png (24.4 KiB)
luis avatar image luis commented ·

This works and thank you so much, i have a trouble because what i want it can be do it by title data or that what i think, i made a new post in the community to get help.

0 Likes 0 ·
brendan avatar image brendan luis commented ·

The simple answer is that Title Data is only meant for data which is set by you, as the developer, and only very occasionally. It is shared by all players exactly as-is. We'll follow up with you in the other thread, though.

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.