I'm trying to use the Peddler gem to create outbound fulfillments in MWS.
The only feedback I'm getting is Excon::Error::BadRequest (Expected(200) <=> Actual(400 Bad Request)
hence it's a little hard to figure out what's going wrong. Here's the line that calls the API (with the values parsed):
@client.create_fulfillment_order("186", "186", 2016-08-01T07:35:48Z, "Test shipment number: 186", "Standard", {"Name"=>"Bert the Destroyer", "Line1"=>"Teststreet", "Line2"=>"123", "Line3"=>"", "DistrictOrCounty"=>"", "City"=>"Testcity", "StateOrProvinceCode"=>"CO", "CountryCode"=>"US", "PostalCode"=>"60401", "PhoneNumber"=>"12345678"}, [{"SellerSKU"=>"4785000045", "SellerFulfillmentOrderItemId"=>"4785000045", "Quantity"=>15}], {:fulfillment_policy=>"FillAll", :notification_email_list=>["[email protected]"]})
I can't seem to figure out how to get a 200 back. Can anyone help?
The actual code:
address = {
"Name" => shipment.order.ship_to_name.to_s,
"Line1" => shipment.order.ship_to_address_1.to_s,
"Line2" => shipment.order.ship_to_address_2.to_s,
"Line3" => "",
"DistrictOrCounty" => "",
"City" => shipment.order.ship_to_city.to_s,
"StateOrProvinceCode" => shipment.order.ship_to_state_code.to_s,
"CountryCode" => shipment.order.ship_to_country_code.to_s,
"PostalCode" => shipment.order.ship_to_zipcode.to_s,
"PhoneNumber" => shipment.order.ship_to_phonenumber.to_s
}
items = []
shipment.m2m_line_item_shipments.each do |m2m|
items << {"SellerSKU" => m2m.vendor_sku.name.to_s, "SellerFulfillmentOrderItemId" => m2m.vendor_sku.name.to_s, "Quantity" => m2m.line_item.actual_quantity }
end
order_comment = "#{shipment.order.store.name} shipment number: " + shipment.id.to_s
opts = {:fulfillment_policy => "FillAll", :notification_email_list => [shipment.order.ship_to_email.to_s] }
created_at = shipment.order.created_at.iso8601
response = @client.create_fulfillment_order(shipment.id.to_s, shipment.id.to_s, created_at, order_comment.to_s, 'Standard', address, items, opts)
order = response.parse
logger.debug "order.inspect: #{order.inspect}"
Edit: After some more digging I found this. I tried sending item quantity as integer and string but the same error occurs:
<Error>
<Type>Sender</Type>
<Code>InvalidRequestException</Code>
<Message>Value AllQuantityZero for parameter is invalid.</Message>
</Error>
After more searching, I found my answer. Turns out this error means that the SKU is out of stock. Great error message amazon! Source: https://sellercentral.amazon.com/forums/message.jspa?messageID=2745103