question

digitalmkt avatar image
digitalmkt asked

GetUserData -The value for key was not valid JSON.

Hello again, I'm trying to update the user data value using the code available here and I'm having the following error:

Data: The value for key city was not valid JSON.

The code is:

        PlayFabClientAPI.UpdateUserData(new UpdateUserDataRequest()

        {

           Data = new Dictionary<string, string>() {

                { "city", "barcelona" },

        } 

        },

        result => Debug.Log("Successfully updated user city"),

        error => {

            Debug.Log("Got error setting user data city");

            Debug.Log(error.GenerateErrorReport());

        });


    }

Am I missing something?

Thanks a lot.

unity3ddata
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

·
Citrus Yan avatar image
Citrus Yan answered

Did you enable the "Require valid JSON for custom data values" option on the API Features page https://developer.playfab.com/en-US/r/t/your_title_id/settings/api-features?

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

digitalmkt avatar image digitalmkt commented ·

Yes, I did it already before.

0 Likes 0 ·
digitalmkt avatar image digitalmkt commented ·

I've tried to change for Internal User Data and the err persists.

I also disable "Require valid JSON for custom data values" saved and re-enable it again with no results.

Thanks.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan digitalmkt commented ·

In your case, "barcelona" is not a valid JSON format, you should disable the "Require valid JSON for custom data values" option, otherwise you'll need to pass a valid JSON representation as data Values.

1 Like 1 ·
digitalmkt avatar image digitalmkt Citrus Yan commented ·

Thanks. It works now.

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.