question

mr22120237 avatar image
mr22120237 asked

UnLockContainerInstance in a loop, error with "Invalid crate Item"

I tried to do a like "Get All Rewards" to get all containers in a mailbox

I can unlock it one by one successfully,but why not in a loop (only 3 times)?

Sometimes it would come up with error:"Invalid crate Item" , but I had checked each "InstanceItemID" exist....

Did anyone know this problem?

or any suggeset on doing similiar function with "Get All Rewards"?

Thanks!

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

·
Rick Chen avatar image
Rick Chen answered

Could you please provide the relevant code snippet, your title id, the player id and the relevant item instances IDs for us to diagnose? If you try unlocking the same item again, does this error still exist? Please understand that the API calls are not 100% guaranteed to be successful. If this error is just some edge case issue, you could implement the exponential retry strategy to retry the failed call.

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

mr22120237 avatar image mr22120237 commented ·

My Title ID : 2AE0B

These is my function to run a loop to get all mails

0 Likes 0 ·
code-1.jpg (73.8 KiB)
code-2.jpg (57.9 KiB)
Rick Chen avatar image Rick Chen ♦ mr22120237 commented ·

I have inspected your title and I noticed that there were errors that APIClientRequestRateLimitExceeded and ContainerNotOwned for the UnlockContainerInstance API.

The APIClientRequestRateLimitExceeded error indicates too many calls in a short burst, you can refer to this document: Safe to retry codes. You can reduce the frequency of calling the APIs and implement the exponential retry strategy to retry the failed call for this type of error.

The ContainerNotOwned error means that the container does not exist in the Player’s inventory. It could be already consumed, removed or never ever exist. A possible situation can be that the UnlockContainerInstance API is called on the same item 2 or more times. From your code, it could be that your Button_GetAllMails() function were called multiple times, or the mailList were containing duplicate item instance id.

1 Like 1 ·
mr22120237 avatar image mr22120237 Rick Chen ♦ commented ·

Thanks for your help~

All playfab API function should be await until it come with result.

After adding something like "await" in my loop , It works perfectly.

Thanks!

0 Likes 0 ·
mr22120237 avatar image mr22120237 commented ·

And here is the Debug in Unity after run the code.

I think iteminstancesID and playerId are not the problem.

Each time will fail to get one (or more) item which I have double check all instance ID and item are in player's inventory.

I just can't figure out why I can do it by clicking each mail one by one , but not in a loop to get all of them.

Is there any problem in my code? (conflict with API call or something?)

Thanks!

0 Likes 0 ·
error-report.jpg (19.6 KiB)
mr22120237 avatar image mr22120237 commented ·

By the way , I can unlock the same item which I failed to get it.

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.