使用Ruby Gem -Peddler来访问MWS API。我们必须发送发货地址。文档说它需要是一个哈希值,但我无法让它工作。
ship_from_address = {
name: "Schmo",
addressline1: "929 Whatever Dr.",
city: "Fun Town",
stateorprovincecode: "XX",
postalcode: "12345"
}
这里是正确设置客户端后对API的实际调用,因为我可以访问请求更简单的其他数据。
plan = client.create_inbound_shipment_plan(ship_from_address,
inbound_shipment_plan_request_items)
这里是amazon documentation的链接。
这是我从API请求地址字段时地址字段的格式。
{"ShipmentData"=>{"member"=>{"LabelPrepType"=>"SELLER_LABEL",
"DestinationFulfillmentCenterId"=>"IND2", "ShipFromAddress"=>
{"City"=>"XXX", "CountryCode"=>"XX", "PostalCode"=>"12345",
"Name"=>"Schmo", "AddressLine1"=>"3434 Smitherens Rd.",
"StateOrProvinceCode"=>"YY", "AddressLine2"=>"#13A"},
"ShipmentId"=>"FBA37ZLXXX", "AreCasesRequired"=>"false",
"ShipmentName"=>"2015-12-22 09:58", "ShipmentStatus"=>"IN_TRANSIT"}}}
有什么想法吗?
1条答案
按热度按时间vxbzzdmp1#
看起来你需要遵守在哈希表中命名键的约定,哈希表的键被转换成大写,所以
addressline1
会变成Addressline1
,但是它应该是AddressLine1
,尝试这样重命名键:注意在Peddler gem的规格中如何命名键-https://github.com/hakanensari/peddler/blob/master/test/integration/test_fulfillment_inbound_shipment.rb#L5我认为这是问题的原因。