使用Ebay Python SDK遇错误码10009:已传必填参数仍报错求助
解决Ebay Python SDK中VerifyAddFixedPriceItem的10009字段缺失错误
我之前处理过一模一样的问题,你这里的核心问题是字段层级不对——Ebay Trading API要求Country、Currency、ListingDuration这些必填字段必须嵌套在Item父节点下,而不是直接放在请求的根字典里。
你现在的代码是把这些字段直接作为顶级键传入api.execute(),但SDK会严格按照API的结构要求解析请求,根级的这些字段不会被识别为Item对象的属性,所以API返回10009错误,认为这些字段缺失。
修正后的代码
只需要把你原来的item字典包裹在Item键下,作为请求体的顶级结构即可:
from ebaysdk.trading import Connection as Trading api = Trading(domain='api.sandbox.ebay.com', config_file='ebay.yaml') # 将原item字典嵌套到Item键中,匹配API的结构要求 request_body = { 'Item': { 'Title': 'Item Title', 'Description': ' This is the description for the Item', 'PrimaryCategory': {'CategoryID': '377'}, 'PrivateListing': 'True', 'ConditionID': '1000', 'Country': 'US', 'Currency': 'USD', 'DispatchTimeMax': '5', 'ListingDuration': 'GTC', 'ListingType': 'FixedPriceItem', 'PaymentMethods': 'PayPal', 'PayPalEmailAddress': 'xxx@gmail.com', 'PictureDetails': { 'PictureURL': 'picture_url', 'PhotoDisplay': 'SuperSize', }, 'Location': 'Los Angeles', # 建议改成美国城市,和Country:US保持一致 'ReturnPolicy': { 'ReturnsAcceptedOption': 'ReturnsAccepted', 'RefundOption': 'MoneyBack', 'ReturnsWithinOption': 'Days_30', 'Description': 'If you change your mind, please return your item within 30 days of receiving it for refund.', 'ShippingCostPaidByOption': 'Buyer' }, 'ShippingDetails': { 'ShippingType': 'Flat', 'ShippingServiceOptions': { 'FreeShipping': 'True', 'ShippingService': 'AU_FastwayCouriers', 'ShippingServiceCost': '0', }, 'InternationalShippingServiceOption': { 'FreeShipping': 'True', 'ShippingServiceCost': '0', 'ShippingService': 'AU_StandardInternational', 'ShippingServiceAdditionalCost': '0', 'ShippingServicePriority': '1', 'ShipToLocation': 'Worldwide', } } } } response = api.execute('VerifyAddFixedPriceItem', request_body) print(response.reply)
额外注意事项
- 我把
Location改成了Los Angeles,因为你设置的Country是US,但原来的Melbourne是澳大利亚城市,这会导致API返回位置不匹配的警告,建议保持国家和城市一致。 - 确保
PictureURL是有效的可访问链接,沙箱环境虽然允许占位,但有效链接能避免不必要的验证错误。
内容的提问来源于stack exchange,提问作者Wookie
相关产品推荐
相关产品推荐

