question

kristindragos avatar image
kristindragos asked

Error with Client Consume Item

I'm using Unity and trying to consume an item from a player's inventory.

ConsumeItemRequest request = new ConsumeItemRequest(){ ItemInstanceId = powerUp.ToString(), ConsumeCount = 1 }; PlayFab.PlayFabClientAPI.ConsumeItem(request, null, OnDataFailure);

I am passing in the instance id that I've defined in my dashboard, but I'm getting this error:

/Client/ConsumeItem: Invalid input parameters ItemInstanceId: must be a hex-encoded number

Is there a place where I can get this number that's tied to the item id in the dashboard? (I'm not seeing anything, so I'm hoping someone can point me in the right direction.)

Thanks!

Player Inventory
10 |1200

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

1 Answer

·
brendan avatar image
brendan answered

The Item Instance ID is the unique identifier for the specific instance of the item in the player's inventory. You can get this from any query of the player's inventory - each item will have a distinct Instance ID. It sounds like the issue is that you're trying to consume by the Item ID, which is the generic ID for the item across all users.

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

kristindragos avatar image kristindragos commented ·

Ah! That makes sense. Let me try that. Essentially, you're saying, I have to retrieve the player's inventory to first get an instance of the item and then use that in the consume item call. (Even if they are stackable?)

0 Likes 0 ·
brendan avatar image brendan kristindragos commented ·

Correct - even a stack has a distinct Instance ID.

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.