-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error 4 'Product ID is required.' using 'findItemsByProduct' when searching via UPC #277
Comments
A quick update to this issue. It appears the generated XML request may be wrong. The output of the request is <?xml version=\'1.0\' encoding=\'utf-8\'?>
<findItemsByProductRequest
xmlns="http://www.ebay.com/marketplace/search/v1/services">
<productId>0885370808278</productId>
</findItemsByProductRequest> I believe the xml should read <?xml version=\'1.0\' encoding=\'utf-8\'?>
<findItemsByProductRequest
xmlns="http://www.ebay.com/marketplace/search/v1/services">
<productId type="UPC">0885370808278</productId>
</findItemsByProductRequest> adding in the type attribute |
OK, now I'm really confused. I enabled debug to see what is happening. In the MD below you can see that the dict is a dict, dict2xml parses it properly, but when passing the dict to execute, the log indicates that the attributes (@attrs) is stripped from the dict. Any ideas? from ebaysdk.finding import Connection as Finding
from ebaysdk.exception import ConnectionError
from ebaysdk.utils import dict2xml
import pandas as pd
Domain = 'svcs.sandbox.ebay.com'
api = Finding(domain=Domain, appid='hiddenapi', debug=True)
UPC = '0885370808278'
request = {'productId': { '#text': UPC,'@attrs': {'type': 'UPC'}}}
display(request)
display(dict2xml(request))
response = api.execute('findItemsByProduct', request)
display(response.dict())
|
I managed to resolve my issue, but I'm not certain if the fix will break something else or not. Changed if '#text' in root:
value = root['#text']
if '@attrs' in root:
- for ak, av in sorted(root.pop('@attrs').items()):
+ for ak, av in sorted(root['@attrs'].items()):
attrs.append(str('{0}="{1}"').format(ak, smart_encode(av))) |
This is has me confused as well. I don't see any difference in the output when running with your change. Maybe you were using an invalid product ID? what version of Python and OS were you on? |
I tried with multiple product id's. I am running on Windows 10, Python 3.6.8. |
Hello.. Having this same problem.. Where did you put your fix? and what is it running against? What is root? Thanks.. |
@phantomodm are you also on a Windows 10 machine? |
This works for me in production env on win10, python 3.7.4. def find_items_by_product_demo():
env = 'production' # sandbox
UPC = '0190198066572'
request = {'productId': {'#text': UPC, '@attrs': {'type': 'UPC'}},
'paginationInput': {'entriesPerPage': 2}}
try:
api = Finding(domain=domains[env], appid=appids[env],
config_file=None, siteid="EBAY-US", https=True,
debug=False)
response = api.execute('findItemsByProduct', request)
except ConnectionError as e:
print(e)
print(e.response.dict())
raise
except Exception:
print('Unexpected exception:')
raise
print(json.dumps(response.dict(), indent=4)) |
I am having issues searching by UPC using findItemsByProduct. I am receiving the error message 'Product ID is required'. Can anyone tell me what I may be doing wrong?
I'm using Python 3.6.8, jupyter==1.0.0
The text was updated successfully, but these errors were encountered: