简体   繁体   中英

How to create a valid request through the eBay trading API and AddItem in python

I have already looked through documentation on both GitHub for the SDK and on the official eBay docs. On the GitHub, it appears that the dictionary in one of the samples is outdated. I tried to use a library to convert the XML from the eBay forum under "Sample: Basic Call" ( https://developer.ebay.com/devzone/xml/docs/reference/ebay/additem.html#Samples ) but I get the same error when making an API call (that an attribute or multiple are missing). I've tried copying the dictionary structure from multiple places but it always ends up returning that an an element is missing.

from ebaysdk.trading import Connection

myitem = {}         # here I have the dict converted from XML
api = Connection(config_file="ebay.yaml", domain="api.sandbox.ebay.com")
api.execute("VerifyAddItem", myitem)               # VerifyAddItem same problem as AddItem

As for the error it comes in the form of something like

ebaysdk.exception.ConnectionError: 'VerifyAddItem: Class: RequestError, Severity: Error, Code: 10009, No <Item.Currency> exists or <Item.Currency> is specified as an empty tag. No <Item.Currency> exists or <Item.Currency> is specified as an empty tag in the request., Class: RequestError, Severity: Error, Code: 10009, No <Item.Country> exists or <Item.Country> is specified as an empty tag. No <Item.Country> exists or <Item.Country> is specified as an empty tag in the request., Class: RequestError, Severity: Error, Code: 10009, No <Item.ListingDuration> exists or <Item.ListingDuration> is specified as an empty tag. No <Item.ListingDuration> exists or <Item.ListingDuration> is specified as an empty tag in the request.'

You can replace the <Item. Name > with whatever tag is missing depending on how I have tried to fix the problem.

The GitHub example item I found ( https://github.com/timotheus/ebaysdk-python/blob/master/samples/trading.py myitem ) gave the same problem (with a different tag) which is why I thought it might be outdated (example was committed 3 years ago).

Also, I am using the old APIs because I don't know how (or if) you can create single listings with the REST APIs.

using a SDK can help avoiding some steps, but to make a successful call you have to understand how the API works and carefully read the documentation.

in the github example, are stated 3 SellerProfiles with their own names: but you need to create them before making the call elsewhere it will return an error.

Beside this, in recent years several nodes has been added and other, like Brand , MPN , ItemSpecifics and other has switched to "Required".

Furthermore ItemSpecifics list (yes are several nodes) depends on the PrimaryCategory/CategoryID , some are required, some other suggested and other optional.

Again, most fields do not accept free text but do have a list of suggested/required values

Needless to say that to get the list of ItemSpecifics you need to call another API .

The cherry on top is that for "OLD Trading API" the call to get ItemSpecifics list has been decommissioned, and therefore need to use the new REST API.

Finally, concerning SDK ... sdk often avoids to reinvent the wheel.. but if it's a wooden wheel...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM