Amazon-SP-API-CSharp icon indicating copy to clipboard operation
Amazon-SP-API-CSharp copied to clipboard

AmazonUnauthorizedException when calling FbaInventory.GetInventorySummariesAsync

Open ProNotion opened this issue 3 years ago • 2 comments

I am trying to get a list of all inventory I've ever had including deleted listings. The data does not appear to be included in the report manager GetProductsAsync results so I am attempting to get it via FbaInventory.GetInventorySummariesAsync however my calls to that endpoint are resulting in an exception and I'm not sure why?

FikaAmazonAPI.AmazonSpApiSDK.Models.Exceptions.AmazonUnauthorizedException: Access to requested resource is denied

Why would special permissions be needed to get inventory data? Am I missing anything?

var searchParams = new ParameterGetInventorySummaries
{
	marketplaceIds = new[] {MarketPlace.UnitedKingdom.ToString()},
	granularityType = Granularity.GranularityTypeEnum.Marketplace,
	granularityId = MarketPlace.UnitedKingdom.ID,
	nextToken = nextToken,
	details = includeDetails
};

return await _amazonConnection.FbaInventory.GetInventorySummariesAsync(searchParams);

ProNotion avatar Oct 22 '22 07:10 ProNotion

//YOU CANT DO THIS 
marketplaceIds = new[] {MarketPlace.UnitedKingdom.ToString()} 

//THIS TRUE
//YOU CANT DO THIS 
marketplaceIds = new[] {MarketPlace.UnitedKingdom.ID} 

abuzuhri avatar Oct 22 '22 08:10 abuzuhri

Is that solve your problem?

abuzuhri avatar Oct 23 '22 01:10 abuzuhri

Perfect - that was exactly the problem! Sorry, I had copied my logic from another request where that line for some reason was working but didn't get an error so have gone back and corrected it elsewhere too. Thanks for pointing out my now obvious error.

ProNotion avatar Oct 23 '22 06:10 ProNotion