timotheus / ebaysdk-python

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

TypeError: expected string or bytes-like object #208

Open iwconfig opened 7 years ago

iwconfig commented 7 years ago

Am I missing something? I really can't see what's wrong here. Why is my header value <class 'NoneType'>? Is this similar to #162 ?

...
api = Trading(appid=APP_ID, config_file=None, debug=True)
response = api.execute('GetMyeBayBuying', {'DetailLevel': 'ReturnAll'})
print(response.dict())
...

Error:

2017-08-09 21:11:52,033 ebaysdk [DEBUG]:execute: verb=GetMyeBayBuying data={'DetailLevel': 'ReturnAll'}
Traceback (most recent call last):
  File "/home/yousir/scripts/dev/venv/lib/python3.5/site-packages/requests/utils.py", line 868, in check_header_validity
    if not pat.match(value):
TypeError: expected string or bytes-like object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ebay-test.py", line 11, in <module>
    response = api.execute('GetMyeBayBuying', {'DetailLevel': 'ReturnAll'})
  File "/home/yousir/scripts/dev/venv/lib/python3.5/site-packages/ebaysdk/connection.py", line 122, in execute
    self.build_request(verb, data, verb_attrs, files)
  File "/home/yousir/scripts/dev/venv/lib/python3.5/site-packages/ebaysdk/connection.py", line 162, in build_request
    self.request = request.prepare()
  File "/home/yousir/scripts/dev/venv/lib/python3.5/site-packages/requests/models.py", line 259, in prepare
    hooks=self.hooks,
  File "/home/yousir/scripts/dev/venv/lib/python3.5/site-packages/requests/models.py", line 306, in prepare
    self.prepare_headers(headers)
  File "/home/yousir/scripts/dev/venv/lib/python3.5/site-packages/requests/models.py", line 440, in prepare_headers
    check_header_validity(header)
  File "/home/yousir/scripts/dev/venv/lib/python3.5/site-packages/requests/utils.py", line 872, in check_header_validity
    "not %s" % (value, type(value)))
requests.exceptions.InvalidHeader: Header value None must be of type str or bytes, not <class 'NoneType'>

Versions:

ebaysdk: 2.1.4
requests: 2.18.3
howardfk commented 4 years ago

Having the same exact error and problem. When using finding and a yaml file for config_file. I’ve even tried using double quotes for everything and using str(‘keywords’). the error always says i have “NoneType”.

api = Connection(domain=dom, config_file=config_name, siteid="EBAY-US", https=True)
request = {'keywords': 'lord of the rings',}
responce = api.execute( "findItemsAdvanced", request)

The error:

Traceback (most recent call last):
  File "Pyto.app/site-packages/requests/utils.py", line 941, in check_header_validity
    if not pat.match(value):
TypeError: expected string or bytes-like object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Documents/Ebay_project/ebay_test.py", line 41, in <module>
    responce = api.execute( "findItemsAdvanced", request)
  File "Documents/site-packages/ebaysdk/connection.py", line 122, in execute
    self.build_request(verb, data, verb_attrs, files)
  File "Documents/site-packages/ebaysdk/connection.py", line 162, in build_request
    self.request = request.prepare()
  File "Pyto.app/site-packages/requests/models.py", line 257, in prepare
    p.prepare(
  File "Pyto.app/site-packages/requests/models.py", line 314, in prepare
    self.prepare_headers(headers)
  File "Pyto.app/site-packages/requests/models.py", line 448, in prepare_headers
    check_header_validity(header)
  File "Pyto.app/site-packages/requests/utils.py", line 944, in check_header_validity
    raise InvalidHeader("Value for header {%s: %s} must be of type str or "
requests.exceptions.InvalidHeader: Value for header {X-EBAY-SOA-SECURITY-APPNAME: None} must be of type str or bytes, not <class 'NoneType'>
jnasti1 commented 3 years ago

I encountered this problem when trying to use the Finding API in the eBay Sandbox (code defaults to the eBay Production server). You can update a few things and you should be ok.

  1. Update ebay.yaml under the Finding API section:

    • point to the Sandbox domain for the Finding API - svcs.sandbox.ebay.com
    • 'appid' contains your Sandbox App ID (Client ID) from your developer.ebay.com account details
  2. Also override the domain used in the Finding API to point to the Sandbox domain: api = Connection(debug=True, domain='svcs.sandbox.ebay.com')

  3. Modify the ebaysdk/finding/__init__.py class contructor to grab your 'appid' from your ebay.yaml file. In the latest release, line 86 should be modified to: self.config.set('appid', self.config.get('appid', None))