question

faniram243@gmail.com avatar image
faniram243@gmail.com asked

hello, unable to update price of ugc item via azure function ?

hi, the code is attached to screenshots. get draft item is working fine, but i think the setup for price options is not right and hence giving errors. Please help ! thanks for answers6413-1.png6414-2.png

apis
1.png (194.4 KiB)
2.png (26.7 KiB)
10 |1200

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

Xiao Zha avatar image
Xiao Zha answered

For UGC items created through the API but without setting the PriceOption property in the API request, if you never save the item in Game Manager and never update the item's PriceOption using the API, the PriceOption property of the item is null, in this case, the PriceOption property and the Price property need to be initialized before adding a new price. So, you may need to add some checking code in your AzureFunction to check if PriceOption and Price are null. Here is the checking code: 6433-image.png


image.png (66.2 KiB)
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.

faniram243@gmail.com avatar image faniram243@gmail.com commented ·

hi, thanks for replies -- status is ok but now i'm getting this error. I even tried to comment cp.UnitAmount = 1 to see if that is causing issue but with it commenting too, same error i am getting.6428-1.png

0 Likes 0 ·
1.png (28.7 KiB)
Xiao Zha avatar image Xiao Zha faniram243@gmail.com commented ·

The error message indicates that there are two identical prices in the Prices list in the UpdateDraftItem API request body. So, if you want to add a new price for the Item, you may first check if the price already exists in the Prices list. If you want to modify an existing price in the Prices list, you can directly traverse the Prices list and modify it.

0 Likes 0 ·
faniram243@gmail.com avatar image faniram243@gmail.com Xiao Zha commented ·

thankyou, now it's working -- directly from unreal engine, i am able to create ugc item and add price too via azure function along with unit amount, everything works -- thank you so much guys !!

0 Likes 0 ·
kylemc@microsoft.com avatar image
kylemc@microsoft.com answered

All that looks correct, but it seems to be hitting an error. The only thing I can think of is maybe cp.Amounts, Item.PriceOptions, or PriceOptions.Prices are null and need initializing.

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

faniram243@gmail.com avatar image faniram243@gmail.com commented ·

hi, so shall i keep like this cp.Amounts = null or ? i'm sorry as i'm fairly new to c#

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha faniram243@gmail.com commented ·

Update: Sorry for the confusion, I was testing with an older version of PlayFabAllSDK which didn't have the UnitAmount property in CatalogPrice. I retest with the latest SDK and update the working code below.

You may initialize the cp.Amounts like this: cp.Amounts = new List<CatalogPriceAmount>{cpa}; Also, there is no UnitAmount property in the CatalogPrice object. And here is the working code you may refer to:

6432-image.png

0 Likes 0 ·
image.png (91.1 KiB)
faniram243@gmail.com avatar image faniram243@gmail.com Xiao Zha commented ·

thank you , it worked but in postman results, unit amount showed null and so i uncommented cp.UnitAmount = 1 just to see, but it gave bad request error. Maybe the code to set unit amount is wrong ?6416-1.png

0 Likes 0 ·
1.png (1.7 KiB)
Show more comments
Show more comments

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.