Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question 404 Not Found on Add Inventory Item

Discussion in 'Economy' started by unity_F59652355ED7ADE23E78, Mar 17, 2022.

  1. unity_F59652355ED7ADE23E78

    unity_F59652355ED7ADE23E78

    Joined:
    Feb 1, 2022
    Posts:
    4
    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()

    Code (CSharp):
    1.  
    2. InventoryItemDefinition itemToBePurchased = await Economy.Configuration.GetInventoryItemAsync(selectedSkin.InventoryID);
    3. PlayersInventoryItem createdInventoryItem = await Economy.PlayerInventory.AddInventoryItemAsync(itemToBePurchased.Id);
    4.  
    Am I missing something? The fact that I can retrieve the definition but I cannot add it to an inventory is a bit frustrating
     
  2. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    176
    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 for a potential workaround. Please let me know if this works for you.
     
  3. unity_F59652355ED7ADE23E78

    unity_F59652355ED7ADE23E78

    Joined:
    Feb 1, 2022
    Posts:
    4
    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.
     

    Attached Files:

    SebT_Unity likes this.
  4. unity_F59652355ED7ADE23E78

    unity_F59652355ED7ADE23E78

    Joined:
    Feb 1, 2022
    Posts:
    4
    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.
     
  5. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    176
    Hi again, thanks for the screenshot and update.
    When possible could you check your project folder / Packages / packages-lock.json
    Search for Remote-Config
    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?
    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.
     
  6. unity_F59652355ED7ADE23E78

    unity_F59652355ED7ADE23E78

    Joined:
    Feb 1, 2022
    Posts:
    4
    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
     
  7. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    176
    Hi again,
    Could you try installing the Economy sample package?
    you can get this by going to Package Manager
    upload_2022-3-18_13-55-45.png

    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
     
  8. mhardy

    mhardy

    Joined:
    Apr 3, 2011
    Posts:
    47
    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",

    image-0022.png

    Note: I tried "com.unity.remote-config": "3.0.0-pre.14" but that causes compile errors.
     
  9. Laurie-Unity

    Laurie-Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    169
    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.
    Code (CSharp):
    1. AuthenticationService.Instance.ClearSessionToken();
    2. 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.
     
  10. mhardy

    mhardy

    Joined:
    Apr 3, 2011
    Posts:
    47
    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.
     
  11. Laurie-Unity

    Laurie-Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    169
    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.
     
  12. Laurie-Unity

    Laurie-Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    169
    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.
     
  13. mhardy

    mhardy

    Joined:
    Apr 3, 2011
    Posts:
    47
    Glad you figured it out, and thanks for the update!
     
  14. unity_Ctri

    unity_Ctri

    Unity Technologies

    Joined:
    Oct 20, 2020
    Posts:
    78
    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?
     
  15. Laurie-Unity

    Laurie-Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    169
    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"