question

fmedina avatar image
fmedina asked

UpdateCharacterReadOnlyData adding unwanted data to CharacterReadOnlyData,UpdateCharacterReadOnlyData adds unnecesary keys to ReadOnlyData

So, after granting a character token to the user, and creating a character, I wanted to give this new character some CharacterReadOnlyData, by making this call from the server:

var Data:testReadOnlyData  = {"progress":{"level":1,"exp":0}};


var updateReadOnlyDataRequest = {PlayFabId : currentPlayerId, CharacterId : newCharacterID, Data:testReadOnlyData }; 
    var resultReadOnly = server.UpdateCharacterReadOnlyData( updateReadOnlyDataRequest );

This works, but the problem is that for some reason the PlayfabID and CharacterID are being added as well:

We use PlayfabId and CharacterId to make the call, but we don't want them in there. Is it a Playfab issue? or am I missing something?

Thank you.

,

So, after granting the player a character token, and successfully added the character to the player, I wanted to give this new character some CharacterReadOnlyData, for this I call from the server:

var testReadOnlyData = {  "progress": { "level": 1, "exp": 0  }};

var updateReadOnlyDataRequest = {PlayFabId : currentPlayerId, CharacterId : newCharacterID, Data : testReadOnlyData }; 
server.UpdateCharacterReadOnlyData( updateReadOnlyDataRequest );

This works, but for some reason the PlaybafId and CharacterId are being added in the CharacterReadOnlyData as well (we need those to make the call, but we don't want them in CharacterReadOnlyData) :

is it a Playfab issue? or am I missing something?

Thank you

Character Data
charreaddata.png (25.5 KiB)
charreaddata.png (25.5 KiB)
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.

Seth Du avatar image Seth Du ♦ commented ·

I have tried to reproduce your issue but no success. This issue always occurs when the request is not well formatted. I am not sure if newCharacterID is a string. If so, it means the issue should be caused by testReadOnlyData. I believe you may need a work around solution for example, always stringify the additional structured parts(value of "progress") in "testReadOnlyData" before sending it to PlayFab.

1 Like 1 ·
fmedina avatar image fmedina Seth Du ♦ commented ·

Thank you for your reply. In the actual code newCharacterID is part is the direct result from server.GrantCharacterToUser (not stringified), and testReadOnlyData is stringified. maybe I should put more chunks:


var tokenResult = server.GrantItemsToUser( { PlayFabId: currentPlayerId, ItemIds: [args.CharacterID] } );
    var charDisplayName = tokenResult.ItemGrantResults[0]["DisplayName"]; 
    var testReadOnlyData = LoadCharacterDefaultData();
    var updateReadOnlyDataRequest = {PlayFabId : currentPlayerId, CharacterId : newCharacterResult["CharacterId"], Data:testReadOnlyData }; 
    var resultReadOnly = server.UpdateCharacterReadOnlyData( updateReadOnlyDataRequest );

testReadOnlyData is only:

function LoadCharacterDefaultData(){
    var testData = {progress: { level:1, exp:0 } };
    return JSON.stringify(testData);
}

0 Likes 0 ·

1 Answer

·
Seth Du avatar image
Seth Du answered

After testing for few times, I believe I can reproduce this issue. A bug will be filed shortly. Thank you for the feedback! I will keep this thread updated when there is feedback from the team. This seems to only happen on Cloud Scirpt.

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.

fmedina avatar image fmedina commented ·

thank you very much for your reply! I'm sorry for explaining it so poorly. I've haven't tried from the client yet but I may need it from cloudscript in the future, so I hope it gets fixed soon.

Thanks again!

0 Likes 0 ·
franklinchen avatar image franklinchen commented ·

Hi @fmedina, it turns out the Data property of UpdateCharacterReadOnlyData's request needs to be a Dictionary<string, string>, so we shouldn't have Data: JSON.Stringify(testObj) it should be Data: {foo: JSON.Stringify(testObj) }.

We have informed the SDK team to list a Dictionary<string, string> rather than an object in doc: https://docs.microsoft.com/en-us/rest/api/playfab/server/character-data/updatecharacterreadonlydata?view=playfab-rest

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.