From c8e33b2981bd30eb3a96292514680f53d8368a57 Mon Sep 17 00:00:00 2001 From: Lev Boyarskiy Date: Thu, 23 Apr 2026 19:56:12 -0700 Subject: [PATCH] Fix batch pricing API: flatten queryParams to top-level properties Amazon changed their SP-API batch pricing endpoints contract on 2026-04-23. The previously accepted nested queryParams format now returns HTTP 400: Requested MarketplaceId is invalid, unsupported, or does not exist. The endpoints affected are: POST /batches/products/pricing/v0/itemOffers POST /batches/products/pricing/v0/listingOffers Previously accepted (now broken): { uri: ..., method: GET, queryParams: { MarketplaceId: ATVPDKIKX0DER, ... } } Now required (flat top-level): { uri: ..., method: GET, MarketplaceId: ATVPDKIKX0DER, ... } Fix: mark QueryParams as [JsonIgnore] in both ItemOffersRequest and ListingOffersRequest, and expose MarketplaceId, ItemCondition, CustomerType as direct [JsonProperty] computed properties delegating to QueryParams. This preserves the existing public API surface while correcting the wire format. --- .../ProductPricing/ItemOffersRequest.cs | 24 +++++++------------ .../ProductPricing/ListingOffersRequest.cs | 15 ++++++++---- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Source/FikaAmazonAPI/Parameter/ProductPricing/ItemOffersRequest.cs b/Source/FikaAmazonAPI/Parameter/ProductPricing/ItemOffersRequest.cs index 6a14ecb0..eeaef0cc 100644 --- a/Source/FikaAmazonAPI/Parameter/ProductPricing/ItemOffersRequest.cs +++ b/Source/FikaAmazonAPI/Parameter/ProductPricing/ItemOffersRequest.cs @@ -28,25 +28,17 @@ public string Uri [JsonProperty("method")] public HttpMethodEnum HttpMethod { get; set; } - //[JsonProperty("headers")] - //public Dictionary Headers { get; set; } - - [JsonProperty("queryParams")] + // Amazon changed their batch API contract: query params must be serialized at the top level, not nested under "queryParams". + [JsonIgnore] public ParameterGetItemOffers QueryParams { get; set; } - ///// - ///// A marketplace identifier. Specifies the marketplace for which prices are returned. - ///// - //[DataMember(Name = "MarketplaceId")] - //public string MarketplaceId { get; set; } - - //[DataMember(Name = "ItemCondition")] - //public ItemCondition ItemCondition { get; set; } + [JsonProperty("MarketplaceId")] + public string MarketplaceId => QueryParams?.MarketplaceId; - //[DataMember(Name = "CustomerType")] - //public CustomerType? CustomerType { get; set; } + [JsonProperty("ItemCondition")] + public ItemCondition ItemCondition => QueryParams?.ItemCondition ?? default; - //[JsonIgnore] - //public string Asin { get; set; } + [JsonProperty("CustomerType")] + public CustomerType? CustomerType => QueryParams?.CustomerType; } } diff --git a/Source/FikaAmazonAPI/Parameter/ProductPricing/ListingOffersRequest.cs b/Source/FikaAmazonAPI/Parameter/ProductPricing/ListingOffersRequest.cs index e3936736..a53c28c9 100644 --- a/Source/FikaAmazonAPI/Parameter/ProductPricing/ListingOffersRequest.cs +++ b/Source/FikaAmazonAPI/Parameter/ProductPricing/ListingOffersRequest.cs @@ -28,10 +28,17 @@ public string Uri [JsonProperty("method")] public HttpMethodEnum HttpMethod { get; set; } - //[JsonProperty("headers")] - //public Dictionary Headers { get; set; } - - [JsonProperty("queryParams")] + // Amazon changed their batch API contract: query params must be serialized at the top level, not nested under "queryParams". + [JsonIgnore] public ParameterGetListingOffers QueryParams { get; set; } + + [JsonProperty("MarketplaceId")] + public string MarketplaceId => QueryParams?.MarketplaceId; + + [JsonProperty("ItemCondition")] + public ItemCondition ItemCondition => QueryParams?.ItemCondition ?? default; + + [JsonProperty("CustomerType")] + public CustomerType? CustomerType => QueryParams?.CustomerType; } }