这是我的设置:
Python 3.4
Using the Trading API
Attempting to call eBay’s “VerifyAddItem”
我在PicURL中标记了我得到错误的位置,并且我试图发布多个带有多个URL的图片.我现在只是尝试两张图片,让我们说http://i.ebayimg.com/picture1和http://i.ebayimg.com/picture2. (我意识到这些不是真实的图片,但这不是我遇到的问题的一部分)
eBay API Documentations声明要指定多张图片,请在单独的PictureDetails.PictureURL元素中发送每个URL.传入的第一个URL将是图库图像,并显示在“查看项目”页面上.所以我尝试通过以下两行无效:
"PictureDetails": {"PictureURL": ["http://i.ebayimg.com/picture1",
"http://i.ebayimg.com/picture2"]}
和
"PictureDetails": [{"PictureURL": "http://i.ebayimg.com/picture1"},
{"PictureURL": "http://i.ebayimg.com/picture2"}]
我分别从eBay的连接中得到以下错误:
VerifyAddItem: Class: RequestError, Severity: Error, Code: 37, Input data is invalid.
Input data for tag <Item.PictureDetails.PictureURL[2]> is invalid or missing. Please
check API documentation.
和
VerifyAddItem: Class: RequestError, Severity: Error, Code: 37, Input data is invalid.
Input data for tag <Item.PictureDetails[2].PictureURL> is invalid or missing. Please
check API documentation.
不幸的是,我已经没有想法了.请帮忙!这是完整的字典,不要担心逻辑,因为我已经验证其他一切正常.
api = Trading(config_file="ebay.yaml", warnings=False)
myitem = {
"Item": {
"Title": Title,
"Description": Description,
"PrimaryCategory": {"CategoryID": p.CategoryValue},
"StartPrice": str(p.Price_sbox.value()),
"CategoryMappingAllowed": "true",
"Country": "US",
"ConditionID": CatID,
"ConditionDescription": p.CondDetail_tedit.toPlainText(),
"Currency": "USD",
"DispatchTimeMax": "1",
"ListingDuration": "GTC",
"ListingType": "FixedPriceItem",
"PaymentMethods": "PayPal",
"PayPalEmailAddress": PayPal,
#############################
###This is where I get the Error
#############################
"PictureDetails": PicURL,
"PostalCode": ZipCode,
"Quantity": str(p.Quantity_sbox.value()),
"ReturnPolicy": {
"ReturnsAcceptedOption": "ReturnsAccepted",
"RefundOption": "MoneyBack",
"Description": "14 days money back, you pay return shipping",
"ReturnsWithinOption": "Days_14",
"ShippingCostPaidByOption": "Buyer" },
"ShippingDetails": {
"ShippingType": "Calculated",
"PaymentInstructions": "1 business days of handling time, usually shipped next day. Make sure your address is correct, especially when shipping to foreign countries.",
"ShippingServiceOptions": {
"FreeShipping": FreeShip,
"ShippingService": ShipService
},
"CalculatedShippingRate": {"OriginatingPostalCode": ZipCode} },
"ShippingPackageDetails": {
"MeasurementUnit": "English",
"WeightMajor": str(p.WeightLbs_sbox.value()),
"WeightMinor": str(p.WeightOz_sbox.value()),
"PackageDepth": str(p.DimensionH_sbox.value()),
"PackageLength": str(p.DimensionL_sbox.value()),
"PackageWidth": str(p.DimensionW_sbox.value()),
"ShippingPackage": "PackageThickEnvelope"},
"ShipToLocations": "Worldwide",
"Site": "US",
"SKU": p.ItemID_ledit.text() } }
IntShip = []
boolint = False
if(p.IntShip1_chbox.isChecked()):
IntShip.append('USPSPriorityMailInternational')
boolint = True
if(p.IntShip2_chbox.isChecked()):
IntShip.append('USPSPriorityMailInternationalLargeFlatRateBox')
boolint = True
if(boolint):
myitem['Item']['ShippingDetails']['ShippingServiceOptions']['InternationalShippingServiceOption'] = IntShip
if(p.BestOffer_chbox.isChecked()):
myitem['Item']['BestOfferDetails'] = {'BestOfferEnabled': 'true'}
#print(myitem)
api.execute('VerifyAddItem', myitem)
print("%s" % api.response.content)
except ConnectionError as e:
for node in api.response.dom().findall('ErrorCode'):
print("error code: %s" % node.text)
if 37 in api.response_codes():
print("Invalid data in request")
print(e)
print(e.response.dict())
解决方法:
好吧没关系…我感到愚蠢……因为我还在沙盒中工作,我正在传递测试照片,其中PicURL列表中的某些网址没有指向有效的照片.
如果其他人得到这些错误,第一种格式是正确的:
"PictureDetails": {"PictureURL": ["http://i.ebayimg.com/picture1",
"http://i.ebayimg.com/picture2"]}