question

Hans Weber avatar image
Hans Weber asked

[SOLVED] Passing on CustomItemData

I have a short question.

I am trying to add an item to a player and then put a custom class on it:

// update the data on the new item
var updateItemRequest = new UpdateUserInventoryItemDataRequest()
{
	PlayFabId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId,              // Way to get PlayfabID
	ItemInstanceId = _itemGranted.ToString(),      // Id of this specific item
	Data = new System.Collections.Generic.Dictionary<string, string> 
        {
        {"BuildingData", JsonConvert.SerializeObject(_buildingData)}
    	}
}; 

var updateItemResult = await serverApi.UpdateUserInventoryItemCustomDataAsync(updateItemRequest);

I am getting the right ItemInstanceId and otherwise I am not quite sure what is wrong.

Thank you for your help.

Edit: this is the class I am trying to convert into json:

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.

Rick Chen avatar image Rick Chen ♦ commented ·

Your code snippet is calling the UpdateUserInventoryItemCustomData API, which looks fine. What is your question?

0 Likes 0 ·
Hans Weber avatar image Hans Weber Rick Chen ♦ commented ·

my problem is, that my custom information is not uploaded to playfab. Might it be possible that uploading a json is not possible here?

EDIT: I have just looked up the definitions for UpdateUserData and UpdateUserInventoryCustomItemData and both need the same criteria for data passed, whit would also include jsons. Therefore that part of my quesiton is answered;

I still don't quite understand why passing data to the item won't work.

EDIT NO2:

I was experimenting a bit and I found out, that when I try to get print the updateItemResult.Result into the debug console I get the error: Object instance not set to an instance of an object

0 Likes 0 ·
Hans Weber avatar image
Hans Weber answered

The problem was, that the class I wanted to upload to playfab was larger than 100 bytes, which is the maximum for CustomItemData in the PlayFab database.

10 |1200

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

Hans Weber avatar image
Hans Weber answered

I have tried rewriting the entire script and I still can't seem to get it to work. Are there maybe some other funcitons that I could use, which do the same job?

10 |1200

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

Hans Weber avatar image
Hans Weber answered

@RickChen I am sorry for bothering you. Do you maybe know what could be wrong?

10 |1200

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

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.