acyace2020 avatar image
acyace2020 asked

PlayFabEconomyAPI.PurchaseInventoryItems (Client) started to require EntityKey?

Per my own experience, the economy v2 api from client side to purchase inventory items via PlayFabEconomyAPI.PurchaseInventoryItems does not require a the entity (of type EntityKey) field to be provided from the Unity SDK, and it worked for quite awhile for us, but at some point it no longer works and results in 400 error with error detail saying nothing. Digging it out and realized we'd need to provide the entity key assembled from PlayFabSettings.staticPlayer.EntityId and PlayFabSettings.staticPlayer.EntityType to make it go through.

I thought if the entity field isn't provided, the caller entity is filled in automatically. Is what's mentioned above a new behaviour?


apisunity3dIn-Game Economy
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.

Simon Cui avatar image Simon Cui commented ·

Yes. The API PurchaseInventoryItems requires Entity to be included in its request body. The documentation maybe not updated to the latest one. You can try to put Entity inside request body instead of using PlayFabSettings.staticPlayer, which works in my test.

0 Likes 0 ·

1 Answer

· avatar image answered

I'll take a look. Specifically, the behavior should be as follows.

If Entity is provided in the request, use that entity for the purchase.

If not and the caller is a player (using a title_player_account token), then use the caller for the purchase.

If not, throw. (This case typically applies if you're using the master_player_account token or a title token).

10 |1200

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

acyace2020 avatar image acyace2020 commented ·

Yeah that's what I thought as it worked for us for a while already. What we did was to leave the entity field alone and called from client/player. It worked from both Unity SDK and direct api calls (from Postman assuming a player token).

but some times earlier, both started to fail. We only got notified by our player few days ago (and verified/fixed) , it's a small part for us pretty late into the game, and we did mostly from server side for purchases, so I wouldn't know when exactly this became the case, i.e., might be this (Feb 23) or last month.

For now what we've done to fix it is to create the entity once player is signed in and attach that to the request.

1 Like 1 ·
acyace2020 avatar image acyace2020 commented ·

Hi Kyle, just realized that it's not just the purchase inventory items, but rather all PlayFabEconomyAPI now requires the entity to be provided when calling from client.

0 Likes 0 · avatar image acyace2020 commented ·

Yeah. We found it in the code too. I'm not sure if it was a regression or always part of public preview. We'll update it to align with the documentation.

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.