question

sam-4 avatar image
sam-4 asked

Economy v2 item IDs

Hi there, I'm looking for any explanation of the item IDs in economy v2 because I can't find anything in the documentation and the API appears to be a bit vague and non-descriptive.

Firstly, when creating items with the CreateDraftItem API, it appears to ignore the specified ID and create a random GUID instead. Is that intentional?

I'll just assume it is and playfab wants to manage its own IDs now, but we need to be able to add our own ID so that we can map playfab items to in-game data.

I see there's a field for AlternateIds, though it's unclear how to use it. Answers to some other questions here tend to suggest that the FriendlyId on the portal is a form of AlternateId, but that's all I can find and I still have no idea what either of them are for or how to use them.

If I try to call CreateDraftItem with an AlternateId, I get error 1071 "invalid alternate ID type". If I try to set the type to "FriendlyId" (with that exact capitalisation), I get error 1110 "an unknown error occurred".

How are these meant to be used? Are there any examples anywhere? Much thanks

In-Game Economy
10 |1200

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

sam-4 avatar image
sam-4 answered

Okay, turns out the unknown error seems to be caused by using a colon (:) character in the ID value. Would this be a bug or intentional? As our ids use this character to separate parts of the id from each other (which comes from Unreal systems) it would be very helpful if we were able to get this working. We were previously able to use the character in our ids with economy v1.

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.

Xiao Zha avatar image Xiao Zha commented ·

Sorry for the inconvenience. We have reported this issue to the team and will notify you if there have any results. Also, you can try to use “_” to separate parts of the id from each other.

0 Likes 0 ·
Xiao Zha avatar image
Xiao Zha answered

The random GUID is generated by PlayFab intentionally. And AlternateIds can be used as your own Item Id. Since in my test the call CreateDraftItem API with AlternatedId works fine, could you share your request body code snippet for us to research? Below is my test code, you can have a look:

 PlayFabEconomyAPI.CreateDraftItem(new PlayFab.EconomyModels.CreateDraftItemRequest
             {
                 Item = new PlayFab.EconomyModels.CatalogItem
                 {
                     Type = "ugc",
                     AlternateIds = new List<PlayFab.EconomyModels.CatalogAlternateId>
                     {
                         new PlayFab.EconomyModels.CatalogAlternateId
                         {
                             Type="FriendlyId",
                             Value="test13"
                         }
                     },
                     Title = new Dictionary<string, string>
                     {
                         { "NEUTRAL", "Neutral title" }
                     }
                 }
             }, result1 =>
             {
                 Debug.Log(result1.Item.AlternateIds[0].Value);
             }, error1 =>
             {
                 Debug.Log(error1.GenerateErrorReport());
             });
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.

sam-4 avatar image sam-4 commented ·

Hi Xiao, this is the Unreal code used for the request:

     const auto Item = MakeShared<PlayFab::EconomyModels::FCatalogItem>();
     Item->Type = TEXT("catalogItem");
     Item->Title.Add(TEXT("neutral"), PrimaryAssetId.ToString()); // Use the asset ID as the title for now
    
     PlayFab::EconomyModels::FCatalogAlternateId AssetId;
     AssetId.Type = TEXT("FriendlyId");
     AssetId.Value = PrimaryAssetId.ToString();
     Item->AlternateIds.Add(AssetId);
            
     PlayFab::EconomyModels::FCreateDraftItemRequest Request;
     Request.Item = Item;
     Request.Publish = true;
     IPlayFabModuleInterface::Get().GetEconomyAPI()->CreateDraftItem(Request, PlayFab::UPlayFabEconomyAPI::FCreateDraftItemDelegate::CreateLambda([=](const PlayFab::EconomyModels::FCreateDraftItemResponse& Response) mutable
     {
    
     }), PlayFab::FPlayFabErrorDelegate::CreateLambda([=](const PlayFab::FPlayFabCppError& Error) mutable
     {
    
     }));
0 Likes 0 ·
Xiao Zha avatar image Xiao Zha sam-4 commented ·

Since your code works fine in my test, are you still getting the same "invalid alternate ID type" error? And please note that you can use the Title Entity Token (obtainable by calling the GetEntityToken API with the Secret Key) to create Items with “catalogItem”,” bundle”,” currency” and “store” item types and “ugc” type items are allowed to be created with both title_player_account level entity token and Title Entity Token.

0 Likes 0 ·
sam-4 avatar image sam-4 Xiao Zha commented ·

Thanks Xiao but I still get the same error. Yes, we're using the entity token retrieved using the secret key for this as it's for a developer tool. The request works fine if not providing any AlternateIds and it successfully creates the item. Only when attempting to provide the FriendlyId does this error occur.

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.