lineofflight / peddler

Amazon Selling Partner API (SP-API) in Ruby
MIT License
307 stars 130 forks source link

Error: Value null at 'marketplaceId' failed to satisfy constraint: Member must not be null) #148

Closed egimenos closed 4 years ago

egimenos commented 4 years ago

Hello,

peddler 2.4.1 Rails: 6.0.3.1 Ruby: 2.7.1

I'm just trying to replicate in irb a test that is working in Amazon Scratchpad:

I define my client (the error remains the same either using the marketplace shortcut or not)

client = MWS.orders(marketplace: "ES", merchant_id: ENV["MERCHANT_ID"])

Inspecting the client object, everything looks as expected:

#<MWS::Orders::Client:0x00007f061c893e78 @marketplace=#<Peddler::Marketplace:0x000055eae794ec60 @id="A1RKKUPIHCS9HS", @country_code="ES", @host="mws-eu.amazonservices.com">, @merchant_id="...">

Then if I try to retrieve the orders: client.list_orders(created_after: 1.month.ago)

I got this error:

Traceback (most recent call last):
        1: from (irb):10
Peddler::Errors::InvalidParameterValue (1 validation error detected: Value null at 'marketplaceId' failed to satisfy constraint: Member must not be null)

I'm sorry if I missing something obvious, thanks in advance.

hakanensari commented 4 years ago

It's somewhat counterintuitive, but this operation does not default to your primary marketplace (because the Amazon API doesn't), so you need to specify which marketplace you're querying. See this example.

egimenos commented 4 years ago

It's somewhat counterintuitive, but this operation does not default to your primary marketplace (because the Amazon API doesn't), so you need to specify which marketplace you're querying. See this example.

You are totally right, that solved my problem.

Thanks a lot!!