I am working on a project that requires access to eBay’s Product API. I am using the getProductDetails
call trying to get the fields containing eBay identification numbers (such as ePID, ISBN, GTIN, etc).
I tried two methods to get this call to produce the fields that I need, but I am only getting a "success" return but with no other details for the Python method and a 500 html response for the XML method. The two methods (XML and Python) I have tried so far are in working examples below. The keys I have obtained from Ebay are: appid, cevid, certid and token, which are saved in a .env file in the same directory as my code files.
I've spent days staring at the incomplete EBay API documentation, and EBay customer support pointed by to the EBay SDK package, which does not interface with the Product API.
Here's the Python GET request method:
root = 'https://svcs.ebay.com' endpoint = '/services/marketplacecatalog/ProductService/v1' headers = {
'X-EBAY-API-IAF-TOKEN': 'Bearer ' + OAuth, 'Content-Type': 'application/x-www-form-urlencoded', 'X-EBAY-SOA-RESPONSE-DATA-FORMAT':'JSON', 'X-EBAY-SOA-SECURITY-APPNAME': AppID} params = {
'X-EBAY-SOA-OPERATION-NAME': 'getProductDetails', 'productDetailsRequest':'[0..*]', 'productDetailsRequest.productIdentifier.ePID':'EPID'+’115115562893’} #example ePID
r = requests.get(root+endpoint, headers=headers, params=params)
I expected output with the Product Details, especially GTIN and other identifiers, but instead I got:
{
'getProductDetailsResponse': [{
'ack': ['Success'], 'version': ['1.3.1'], 'timestamp': ['2021-12-02T17:34:18.510Z']}]}
With the XML POST method, the code is:
root = 'https://svcs.ebay.com' endpoint = '/services/marketplacecatalog/ProductService/v1' target_url = root + endpoint xml_request = """<?xml version="1.3.1" encoding="utf-8"?> <getProductDetailsRequest> <productDetailsRequest> <productIdentifier> <ePID>EPID115115562893</ePID> #random ePID number </productIdentifier> <dataset>DisplayableProductDetails</dataset> </productDetailsRequest> </getProductDetailsRequest>""" headers = {
'X-EBAY-API-IAF-TOKEN': 'Bearer ' + OAuth, 'Content-Type': 'application/x-www-form-urlencoded', 'Version': '1.3.1', 'X-EBAY-SOA-RESPONSE-DATA-FORMAT':'JSON', 'X-EBAY-SOA-SECURITY-APPNAME': AppID} r = requests.post(target_url, data=xml_request, headers=headers)
However this produces a 500 HTTP response.
I would be grateful for any help making a call that returns the eBay product identification numbers (ePID, ISBN, GTIN, etc). Thank you