I am using Unity 6 latest version with the latest Economy package.
My intention is to get from Economy the inventory items of the player bya list of Items IDS as described in the documentation page:
[https://docs.unity.com/ugs/en-us/manual/economy/manual/SDK-player-inventory.](https://Player Inventory Doc)
GetInventoryOptions options = new GetInventoryOptions();
options.InventoryItemIds = new List<string>
{
"FERTILIZER_BASIC",
"FERTILIZER_MEDIUM",
"FERTILIZER_STRONG",
"HARVEST_STRAWBERRY",
"HARVEST_TOMATO",
"SEED_STRAWBERRY"
};
try
{
GetInventoryResult inventoryResult = await EconomyService.Instance.PlayerInventory.GetInventoryAsync(options);
List<PlayersInventoryItem> listOfItems = inventoryResult.PlayersInventoryItems;
foreach (var item in listOfItems)
{
Debug.Log(item.InventoryItemId);
}
return true;
}
If I try to run this I will get an exception with the following message.
Unity.Services.Economy.EconomyException: HTTP/1.1 400 Bad Request ---> Unity.Services.Economy.Internal.Http.HttpException: (400) HTTP/1.1 400 Bad Request
at Unity.Services.Economy.Internal.Http.ResponseHandler.HandleAsyncResponse (Unity.Services.Economy.Internal.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) [0x00082] in .\Library\PackageCache\com.unity.services.economy\Runtime\Generated\Runtime\Http\ResponseHandler.cs:120
at Unity.Services.Economy.Internal.Http.ResponseHandler.HandleAsyncResponse[T] (Unity.Services.Economy.Internal.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) [0x00001] in .\Library\PackageCache\com.unity.services.economy\Runtime\Generated\Runtime\Http\ResponseHandler.cs:226
at Unity.Services.Economy.Internal.Apis.Inventory.InventoryApiClient.GetPlayerInventoryAsync (Unity.Services.Economy.Internal.Inventory.GetPlayerInventoryRequest request, Unity.Services.Economy.Internal.Configuration operationConfiguration) [0x0018f] in .\Library\PackageCache\com.unity.services.economy\Runtime\Generated\Runtime\Apis\InventoryApi.cs:185
at Unity.Services.Economy.PlayerInventoryInternal.GetNextInventory (System.String afterPlayersInventoryItemId, Unity.Services.Economy.GetInventoryOptions options) [0x000fb] in .\Library\PackageCache\com.unity.services.economy\Runtime\PlayerInventory.cs:134
--- End of inner exception stack trace ---
at Unity.Services.Economy.PlayerInventoryInternal.GetNextInventory (System.String afterPlayersInventoryItemId, Unity.Services.Economy.GetInventoryOptions options) [0x001df] in .\Library\PackageCache\com.unity.services.economy\Runtime\PlayerInventory.cs:146
at Unity.Services.Economy.PlayerInventoryInternal.GetInventoryAsync (Unity.Services.Economy.GetInventoryOptions options) [0x00027] in .\Library\PackageCache\com.unity.services.economy\Runtime\PlayerInventory.cs:106
I discovered that if I use up to 5 items in the list that I am passing in the function options, I can run it without error, and I get the expected result. But if I try to use more than 5 IDS, I get this error.
Kinda:
Its Work:
GetInventoryOptions options = new GetInventoryOptions();
options.InventoryItemIds = new List<string>
{
"FERTILIZER_BASIC",
"FERTILIZER_MEDIUM",
"FERTILIZER_STRONG",
"HARVEST_STRAWBERRY",
"HARVEST_TOMATO"
};
But if i try more IDS in this list… Exception…
This seems like a bug to me.
The question now is: How can I achieve this goal? My real need is to check if the player has all the items from my InventoryItemDefinition list, which I have previously retrieved. I have more than 200 items registered in the system, and at the moment I can’t search for anything more than 5 items.
Please. Could anyone gimme some help?