这是我的设置:
Python 3.4
使用交易API
试图打电话给eBay的“VerifyAddItem”
我在PicURL
中标记了我收到错误的位置,并且我正在尝试发布包含多个网址的多张图片。我目前正在尝试两张图片,让我们说http://i.ebayimg.com/picture1
和http://i.ebayimg.com/picture2
。 (我意识到这些不是真实的图片,但这不是我遇到的问题的一部分)
eBay API文档说明To specify multiple pictures, send each URL in a separate, PictureDetails.PictureURL element. The first URL passed in will be the Gallery image and appears on the View Item page.
所以我尝试通过以下两行无效:
"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())
答案 0 :(得分:5)
好吧没关系......我感到愚蠢......因为我还在沙盒中工作,我正在传递测试照片,其中列表PicURL
中的某些网址没有指向有效的照片。
如果其他人收到这些错误,第一种格式是正确的格式:
"PictureDetails": {"PictureURL": ["http://i.ebayimg.com/picture1",
"http://i.ebayimg.com/picture2"]}