eBay API - addItem ShipToLocation 仅保存最后一个值

eBay API - addItem ShipToLocation save only last value

这是我第一次接触 eBay API,一开始我遇到了问题。我在 python 中编码,我正在尝试调用 addItem,但我无法正确定义国际运输选项。

我想以 2.50 英镑的价格将我的商品寄往国内,寄往亚洲、日本、澳大利亚的费用为 20 英镑,寄往欧洲、欧盟、德国的费用为 10 英镑。而且我不知道如何声明它...

到目前为止我尝试了什么?

 "ShippingDetails": {
             "GlobalShipping": "true",
             "ShippingType": "Flat",
             "ShippingServiceOptions": {
                 "ShippingService": "UK_OtherCourier",
                 "ShippingServiceCost": "2.50",
             },
             "InternationalShippingServiceOption": {
                 "ShippingService": "UK_RoyalMailAirmailInternational",
                 "ShippingServiceCost": "10",
                 "ShipToLocation": "Europe",
                 "ShipToLocation": "EuropeanUnion",
                 "ShipToLocation": "DE"
             }
         }

但是当我 运行 该代码时,我的列表只有 2.50GBP 的国内运费和 10GBP 的德国运费(仅保存最后一个 ShipToLocation)。如何正确设置带费用的送货区域?

在 Python 词典中,您不能提供重复的值。

您在单个字典中写了三次 ShipToLocation,因此系统只考虑了最后一个。

您可以使用以下方法。

"ShippingDetails": {
             "GlobalShipping": "true",
             "ShippingType": "Flat",
             "ShippingServiceOptions": {
                 "ShippingService": "UK_OtherCourier",
                 "ShippingServiceCost": "2.50",
             },
             "InternationalShippingServiceOption": {
                 "ShippingService": "UK_RoyalMailAirmailInternational",
                 "ShippingServiceCost": "10",
                 "ShipToLocation": ["Europe","EuropeanUnion","DE"]
             }
         }

您应该在列表中写入 ShipToLocation 值。

现在,当您转换 dict_to_xml 时,Python 库将自动管理在 xml 标签中。

以下是转换 dict_to_xml 和 xml_to_dict 的最佳库之一。

https://github.com/Shopify/pyactiveresource/tree/master/pyactiveresource