question

Fabricio Anzorena avatar image
Fabricio Anzorena asked

Display Properties for User Generated Content?

I'm trying to set the DisplayProperties when creating a draft item in Unity, but i keep getting a "Invalid input parameters" error.

I've tried a plain JSON string and an object using JsonUtility.ToJson

Does anyone know what's the correct format to be placed in the DisplayProperties parameter?

apissdksentitiesContent
3 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.

Sarah Zhang avatar image Sarah Zhang commented ·

Could you please provide the sample code for our reference?

0 Likes 0 ·
Fabricio Anzorena avatar image Fabricio Anzorena Sarah Zhang commented ·
var draftRequest = new CreateDraftItemRequest
{
    Item = new CatalogItem
    {
        Type = "ugc",
        ContentType = contentType,
        AlternateIds = new List<CatalogAlternateId>() {new CatalogAlternateId(){Type = "FriendlyId", Value = levelId}},
        Title = new Dictionary<string, string>
        {
            {"NEUTRAL", displayName}
        },
        Contents = new List<Content> { fileContent },
        DisplayProperties = JsonUtility.ToJson(new LevelProperties
        {
            plays = 0,
	    wins = 0
        }),
        DisplayVersion = "1"
    },
    Publish = true
};
PlayFabEconomyAPI.CreateDraftItem(draftRequest, OnDraftComplete, OnRequestError);

That's what a sample draft that i'm trying to setup. LevelProperties is a serializable struct with the fields just to generate the json string.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Fabricio Anzorena commented ·

Thanks for your detailed sample code. We will test the code using Unity and PlayFab Unity SDK.

0 Likes 0 ·

1 Answer

·
JayZuo avatar image
JayZuo answered

From PlayFab REST API, we can see DisplayProperties is an arbitrary JSON blob. While in REST API, it's a JSON blob, then in Unity, it should be an object as the SDK will automatically serialize the object to JSON. Thus, you can change your code to:

DisplayProperties = new LevelProperties
{
    plays = 0,
    wins = 0
},
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.

Fabricio Anzorena avatar image Fabricio Anzorena commented ·

That worked! 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.