如何在Python ebay sd中添加多张图片

2024-04-29 14:10:19 发布

您现在位置:Python中文网/ 问答频道 /正文

以下是我的设置:

Python 3.4

Using the Trading API

Attempting to call eBay's "VerifyAddItem"

我在PicURL中标记了出错的位置,并尝试用多个url发布多张图片。让我先说两张照片。(我意识到这些不是真的照片,但这不是我遇到的问题的一部分)

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"]}

以及

^{pr2}$

我从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())

Tags: theinapidataifisvalueitem
1条回答
网友
1楼 · 发布于 2024-04-29 14:10:19

别担心。。。我觉得很傻。。。因为我仍然在沙盒中工作,所以我在传递测试照片,其中列表PicURL中的一些URL没有指向有效的照片。在

如果其他人出现这些错误,第一种格式是正确的:

"PictureDetails": {"PictureURL": ["http://i.ebayimg.com/picture1",
                                  "http://i.ebayimg.com/picture2"]}

相关问题 更多 >