Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Fabricio Anzorena · Nov 29, 2021 at 09:33 PM · apissdksentitiesContent

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?

Comment

People who like this

0 Show 3
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sarah Zhang · Nov 30, 2021 at 08:29 AM 0
Share

Could you please provide the sample code for our reference?

avatar image Fabricio Anzorena Sarah Zhang · Nov 30, 2021 at 05:49 PM 0
Share
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.

avatar image Sarah Zhang Fabricio Anzorena · Dec 07, 2021 at 01:31 AM 0
Share

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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Jay Zuo · Dec 10, 2021 at 09:20 AM

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
},
Comment
Fabricio Anzorena
drmike

People who like this

2 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fabricio Anzorena · Dec 15, 2021 at 07:35 PM 0
Share

That worked! Thank you.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    11 People are following this question.

    avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

    Related Questions

    What should be used to integrate Chat System in Playfab Groups/Clans? 3 Answers

    How to download content from cdn? 1 Answer

    Having trouble with Get content from CDN to Update my game's version in Unreal Engine 4 0 Answers

    Can we create or host events in Playfab's Clan/Guild? 2 Answers

    How to edit Entity Access Policy? 2 Answers

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges