Introduction to Ebay API with python: The Trading API - Part 3 - LinuxConfig.org

This is the third article of the series dedicated to Ebay APIs and their use via python. In the first article we saw how to setup our working environment, creating a developer and a sandbox "test" account, generating our API keys and installing the python SDK.
This is a companion discussion topic for the original entry at https://linuxconfig.org/introduction-to-ebay-api-with-python-the-trading-api-part-3

Hi there. I followed your article and set up an account on the ebay developer forum. I tried executing the AddItem API request but running into an error like this

2020-01-16 11:59:37,982 ebaysdk [ERROR]:AddItem: Class: RequestError, Severity: Error, Code: 931, Auth token is invalid. Validation of the authentication token in API request failed.

2020-01-16 11:59:37,982 ebaysdk [ERROR]:AddItem: Class: RequestError, Severity: Error, Code: 931, Auth token is invalid. Validation of the authentication token in API request failed.
Traceback (most recent call last):
File “add_itemtest.py”, line 37, in
api.execute(“AddItem”, request)
File “/home/user/ebay_django/venv/lib/python3.6/site-packages/ebaysdk/connection.py”, line 127, in execute
self.error_check()
File “/home/user/ebay_django/venv/lib/python3.6/site-packages/ebaysdk/connection.py”, line 222, in error_check
raise ConnectionError(estr, self.response)
ebaysdk.exception.ConnectionError: ‘AddItem: Class: RequestError, Severity: Error, Code: 931, Auth token is invalid. Validation of the authentication token in API request failed.’

even though I’m using the token generated on the site. Can you please tell me what must be the issue?

From what I read, the token you are using is not valid. Are you sending your API request to the sandbox or to the production ? If you use a token generated for production on sandbox, it will not work (and vice-versa).

From ebay page:

When using the name/value pairs in the URL message format, an array notation is required for multiple filter values, as shown in the following example (line breaks added for readability):

&itemFilter(0).name=ListingType
&itemFilter(0).value(0)=FixedPrice
&itemFilter(0).value(1)=AuctionWithBIN

I use below and it works fine but only for one ListingType at a time.

request = {
‘keywords’: ‘iphone’,
‘itemFilter’: [
{‘name’: ‘ListingType’, ‘value’: ‘Auction’}
],
‘paginationInput’: {
‘entriesPerPage’: 10,
‘pageNumber’: 1
},
‘sortOrder’: ‘StartTimeNewest’
}
I tried adding another ‘value’: ‘’ on same line but it only uses the fist one and issues no error.
What would be the python syntax that includes both values - FixedPrice and AuctionWinBIN?

Thanks,

Hi, I tried this code, and it always give me errors like “Code: 240, The item cannot be listed or modified. The item cannot be listed or modified. The title and/or description may contain improper words, or the listing or seller may be in violation of eBay policy.”. Iv’e tried it word for word with your example and tried changing the description and location related setting to be specific to me, is there anything else im missing? what I’m using right now is: { "Item": { "Title": "Professional Mechanical Keyboard", "Country": "US", "Location": "US", "Site": "US", "ConditionID": "1000", "PaymentMethods": "PayPal", "PayPalEmailAddress": "NotGivingThisOutSoIChangedThisAsYouCouldGuess.com", "PrimaryCategory": {"CategoryID": "33963"}, "Description": "A really nice mechanical keyboard!", "ListingDuration": "Days_10", "StartPrice": "150", "Currency": "USD", "ReturnPolicy": { "ReturnsAcceptedOption": "ReturnsAccepted", "RefundOption": "MoneyBack", "ReturnsWithinOption": "Days_30", "returnDescription": "If you are not satisfied, return the keyboard.", "ShippingCostPaidByOption": "Buyer" }, "ShippingDetails": { "ShippingServiceOptions": { "FreeShipping": "True", "ShippingService": "USPSMedia" } }, "DispatchTimeMax": "3", "ItemSpecifics": { "NameValueList": [ {"Name": "Brand", "Value": "The ocean"}, {"Name": "MPN", "Value": ""}, {"Name": "Type", "Value": "Top-Loading"} ] } } }
Also just to confirm this is the request im sending, not all my code