timotheus / ebaysdk-python

eBay API SDK for Python
https://developer.ebay.com/tools/sdks
Other
796 stars 321 forks source link

Cannot fetch product via ePID? #263

Open austinpgraham opened 5 years ago

austinpgraham commented 5 years ago

Here is a small snippet of code:

class EbayFetcher():

    def __init__(self):
        self.appID = <appid>
        self.api = Connection(appid=self.appID, config_file=None)

    def fetch_product(self, identifier):
        arg = '<productId type="ReferenceID">{}</productId>'.format(identifier)
        response = self.api.execute('findItemsByProduct', arg)
        return response if response.reply.ack == "Success" else None

When playing with this, I find the majority of the time I get an item not found error (invalid numeric value I believe is the exact text). Is there something obviously wrong here?

austinpgraham commented 5 years ago

If anyone stumbles upon this, findItemsByProduct is straight broken. Use findItemsAdvanced instead with keyword=UPC/MPN/ISBN/etc

fsmosca commented 4 years ago

@austinpgraham

The productid type is most likely the issue. From your code it requires an eBay Product ID (ePID). See Ref.

Here is a modified version of your code. I am using ebay product id, it worked.

class EbayFetcher():

    def __init__(self, appid, domain):
        self.appID = appid
        self.domain = domain
        self.api = Finding(appid=self.appID,
                           domain=self.domain,
                           config_file=None)

    def fetch_product(self, identifier):
        arg = '<productId type="ReferenceID">{}</productId>'.format(identifier)
        response = self.api.execute('findItemsByProduct', arg)
        return response.dict() if response.reply.ack == "Success" else None

if __name__ == '__main__':
    ePID = '4032159822'
    a = EbayFetcher(appids['production'], domains['production'])
    result = a.fetch_product(ePID)
    print(f'result: {result}')

Can you post an ebay product id that does not work in your case?

Ref: https://developer.ebay.com/DevZone/finding/CallRef/findItemsByProduct.html