Search code examples
pythonebay-api

eBay API - addItem ShipToLocation save only last value


This is my first contact with eBay API and I have problem at the beginning. I am coding in python and I am trying to call addItem, but I cant define properly international shipping options.

I would like to send my item domestic for 2.50GBP, and international to Asia, Japan, Australia for 20GBP and Europe, EuropeanUnion, Germany for 10GBP. And I have no idea how to declare it...

What I was tried so far?

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

But when I run that code my listing has only domestic shipping for 2.50GBP and shipping to Germany for 10GBP (only last ShipToLocation is saved). How to set properly shipping regions with costs?


Solution

  • In Python Dictionary you are not allow to give duplicate value.

    You have write ShipToLocation three times in single dict, due to that reason system have consider only last one.

    You can do using following method.

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

    you should write ShipToLocation value in list.

    Now when you convert dict_to_xml then Python library will automatic manage in xml tag.

    Following is one of the best library for converting dict_to_xml and xml_to_dict.

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