404 Not Found on Add Inventory Item

Does anyone have working examples of AddInventoryItemAsync? My current code can successfully retrieve the Inventory Item definition but returns a 404 error when i try to call AddInventoryItemAsync()

InventoryItemDefinition itemToBePurchased = await Economy.Configuration.GetInventoryItemAsync(selectedSkin.InventoryID);
PlayersInventoryItem createdInventoryItem = await Economy.PlayerInventory.AddInventoryItemAsync(itemToBePurchased.Id);

Am I missing something? The fact that I can retrieve the definition but I cannot add it to an inventory is a bit frustrating

Hi there,
Thanks for taking the time to post this.

Could you share what packages you have included for economy within you manifest file?
A screenshot of the Package Manager would work great. You can access the Package Manager by going to your Unity Editor and clicking on Window > Package Manager.
We have a known issue at the moment that points to an older version of a dependent package. This should be fixed in the next version of Economy.

See the following [forum ]( RemoteConfig / UGS Economy: configType keeps switching to "economy" ">RemoteConfig / UGS Economy: configType keeps switching to “economy”)for a potential workaround. Please let me know if this works for you.

Thanks for getting back to me so quickly!
Here is my package manager.
I’ll give the workaround a try and get back to you.

1 Like

Hello,

Unfortunately the workaround did not work for me. Just due to the fact that I am able to retrieve the InventoryItemDefinition I think we can rule out a configuration issue.

Any other potential workarounds or is the best bet just to wait for a patch?

Thanks for your time.

Hi again, thanks for the screenshot and update.
When possible could you check your project folder / Packages / packages-lock.json
Search for Remote-Config
7974408--1023216--upload_2022-3-18_8-52-42.png
What version do you have located?

Additionally can you proceed to Project Folder / Library / Package Cache
And verify what version you have located in that folder?
7974408--1023219--upload_2022-3-18_8-54-0.png

Thanks for that additional detail.
It may look like we have to wait for a new release of economy for this fix. I will continue investigating and get back to you as soon as possible.

Morning,

All references to remote-config-runtime both in packages-lock and Package Cache reference version 3.0.0-pre.19.

Would it be possible to rollback to a previous Economy version to be able to use the AddInventoryItemAsync() function?

Thanks again

Hi again,
Could you try installing the Economy sample package?
you can get this by going to Package Manager

Once the sample is installed you will get a samples code to AddInventoryItemAsync in the InventoriesUIExample.

Let me know if that code works for you.
I had a 404 error as well but after a few moments everything went through

Please keep me posted.

Best,
Seb

I’m having the exact same problem, with the same code - but only for new inventory items. I added a new item last night, but when I try to AddInventoryItemAsync, 404. GetInventoryItemAsync works fine and returns the item.

I downloaded the sample, same issue. It will list all my inventory items (old and the new one). But ‘Add Item To Inventory’ only works on the items added prior to last night, not my new item.

relevant manifest.json…
“com.unity.remote-config”: “3.0.0-pre.13”,
“com.unity.services.analytics”: “2.0.7-pre.7”,
“com.unity.services.authentication”: “1.0.0-pre.37”,
“com.unity.services.cloudsave”: “1.0.0-pre.3”,
“com.unity.services.economy”: “1.0.0-pre.8”,

8004254--1029431--image-0022.png

Note: I tried “com.unity.remote-config”: “3.0.0-pre.14” but that causes compile errors.

Hi @unity_F59652355ED7ADE23E78 & @mhardy ,

Our engineers are investigating something that may be related to the issues you have run into. Can I ask you to try something and let us know if it resolves your issues?

Can you try resetting the playerID. We are specualting that the issue might be related to configuration caching.
You can force the playerID to reset by clearing the session token and signiing out of the Authentication service.

e.g.

AuthenticationService.Instance.ClearSessionToken();
AuthenticationService.Instance.SignOut();

Feel free to DM me any debug logging, project deatils, code snippets or further into that might help us resolve your issue.

Actually, it appears fixed today. Did they make changes on the backend? The 404 just stopped, and that item now shows up in my Inventory. I’ve tested via Editor and a device.

Delighted to hear that it appears to be working for you today @mhardy , I’ve forwarded the information to my engineering colleagues.

Your experience does lend weight to their theory about a bug in the configuration caching. We think your cache has now naturally exprired and a new updated configuratoin was pulled when you ran the code yesterday, so the underlying bug is still there, but we now have more to go on and are actively investigating it.

Thanks for your help, I’ll update this thread when I have more news to share.

Following up on this thread.

We have now identified the source of this issue and are working on a fix. I can confrim that the reason @mhardy 's issue resolved itself was because the player’s cache invalidated itself naturally after 24 hours.

The scenario is as follows:

  1. The player interacts with economy
  2. Their economy configuration is changed on the dashboard and published
  3. The player retrieves a new configuration (within 24hr from initial interaction)
  4. The player interacts with economy but the service uses their old configuration in the background

The problem doesn’t always occur, but we have been able to reproduce it in testing.

It is also important to note that there is a natural delay between steps 3 & 4 above (our tests suggest 100ms - 2s), while the cache is updated to the latest values. So there is a chance that new items added to the configuration since the last interaction might not be immediately available, so a delay between retrieving the configuration and interacting with the player inventory would be prudent.

Glad you figured it out, and thanks for the update!

Hey everyone,

Appreciate the patience and hard work in dealing with this issue.
Happy to report I’ve had word that the issue has been resolved. Can folks experiencing it here confirm it’s all good now?

Hi Everyone,

We have published an Experimental update that resolves the caching issue described in this thread. We will keep an eye on the experimental update for a couple of weeks to check there are no further issues before moving it to Preview.

Warning, there are some breaking changes in this experimental release, you will need to change the namespace and update some API calls as we have moved things around a bit to bring more consistency across UGS packages. You may also need to update other UGS packages in your project. Take a look at the Changelog in the Package manager for each impacted package for more information on specific changes.

You can access the new experimantal Economy package from the Package Manager in the Editor or by updatng your Packages/manifest.json to use "com.unity.services.economy": "2.0.1-exp.2"