易趣Python查找API中的身份验证错误

易趣Python查找API中的身份验证错误,python,yaml,Python,Yaml,我正在尝试使用ebay.yaml文件快速将我的应用程序密钥(特别是我的应用程序id)传递到查找API中。但是,即使文件与程序位于同一目录中,每次运行程序时都会引发此异常: 2020-01-22 23:45:34,335 ebaysdk [DEBUG]:execute: verb=findItemsByKeywords data={'keywords': 'buffalo nickel coin', 'itemFilter': [{'name': 'condition', 'va

我正在尝试使用ebay.yaml文件快速将我的应用程序密钥(特别是我的应用程序id)传递到查找API中。但是,即使文件与程序位于同一目录中,每次运行程序时都会引发此异常:

    2020-01-22 23:45:34,335 ebaysdk [DEBUG]:execute: verb=findItemsByKeywords data={'keywords': 'buffalo 
    nickel coin', 'itemFilter': [{'name': 'condition', 'value': 'new'}], 'paginationInput': 
    {'entriesPerPage': 10, 'pageNumber': 1}, 'sortOrder': 'PricePlusShippingLowest'}                                                                                           
    Traceback (most recent call last):                                                                                        
    File "/usr/lib/python3/dist-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 "FindByKeywords.py", line 21, in <module>                                                                            
    response = api.execute('findItemsByKeywords', request)                                                                
    File "/usr/local/lib/python3.6/dist-packages/ebaysdk/connection.py", line 122, in execute                                 
    self.build_request(verb, data, verb_attrs, files)                                                                     
    File "/usr/local/lib/python3.6/dist-packages/ebaysdk/connection.py", line 162, in build_request                           
    self.request = request.prepare()                                                                                      
    File "/usr/lib/python3/dist-packages/requests/models.py", line 259, in prepare                                            
    hooks=self.hooks,                                                                                                     
    File "/usr/lib/python3/dist-packages/requests/models.py", line 306, in prepare                                            
    self.prepare_headers(headers)                                                                                         
    File "/usr/lib/python3/dist-packages/requests/models.py", line 440, in prepare_headers                                    
    check_header_validity(header)                                                                                         
    File "/usr/lib/python3/dist-packages/requests/utils.py", line 872, in check_header_validity                               
    "bytes, not %s" % (name, value, type(value)))                                                                       
    requests.exceptions.InvalidHeader: Value for header {X-EBAY-SOA-SECURITY-APPNAME: None} must be of 
    type str or bytes, not <class 'NoneType'> 
如果我将config_file设置为None,并将我的app id显式地传递到appid参数中,程序就会工作。ebay.yaml只是没有被正确识别。

以下内容适合我:

from ebaysdk.finding import Connection as Finding

yaml_path='C:/Users/Public/ebay/eBay_API/ebay_1.yaml' #path: yaml file location
api = Finding(config_file=yaml_path, siteid='EBAY-US')
request = {
    'keywords': 'buffalo nickel coin',
    'itemFilter': [
        {'name': 'condition', 'value': 'new'}
    ],
    'paginationInput': {
        'entriesPerPage': 10,
        'pageNumber': 1
    },
    'sortOrder': 'PricePlusShippingLowest'
}
response = api.execute('findItemsByKeywords', request)
print(response.reply.paginationOutput)
// {'pageNumber':'1','EntriesPage':'10','totalPages':'982','totalEntries':'9813'}

有关易趣API的更多详细信息:

from ebaysdk.finding import Connection as Finding

yaml_path='C:/Users/Public/ebay/eBay_API/ebay_1.yaml' #path: yaml file location
api = Finding(config_file=yaml_path, siteid='EBAY-US')
request = {
    'keywords': 'buffalo nickel coin',
    'itemFilter': [
        {'name': 'condition', 'value': 'new'}
    ],
    'paginationInput': {
        'entriesPerPage': 10,
        'pageNumber': 1
    },
    'sortOrder': 'PricePlusShippingLowest'
}
response = api.execute('findItemsByKeywords', request)
print(response.reply.paginationOutput)