- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2023 04:53 PM
using the Shopping API Class, I've constructed the YAML as so :
open.api.ebay.com:
iaf_token: myToken
appid: myappid
certid : mycertid
version: 799
Yet I received this error:
'GetSingleItem: Class: RequestError, Severity: Error, Code: 1.33, Token not available in request. Token not available in request. Please specify a valid token as HTTP header.'
{'Timestamp': '2023-03-21T23:08:05.329Z', 'Ack': 'Failure', 'Errors': {'ShortMessage': 'Token not available in request.', 'LongMessage': 'Token not available in request. Please specify a valid token as HTTP header.', 'ErrorCode': '1.33', 'SeverityCode': 'Error', 'ErrorClassification': 'RequestError'}, 'Build': 'E1199_CORE_APILW_19146596_R1', 'Version': '1199'}
I've included iaf_token as per the git hub documentation of the shopping API (https://github.com/timotheus/ebaysdk-python/tree/master/ebaysdk/shopping).
Would anyone be able to help?
Solved! Go to Best Answer
Accepted Solutions
python - ebaysdk - Shopping API, Token not found, yet included in YAML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 10:21 AM
hmmm,
api = Shopping(config_file='./ebay.yaml', siteid='EBAY-GB',https=True,warnings=True,debug=True)
works fine for me.
Are there any typos in iaf_token: in the yaml file? such as iaf-token? It will set a variable for anything listed in the yaml, used or not, even if it is incorrect. s.request.headers is another place to look to verify. Could also be something in how things are imported.
These are all working for me:
sdk import
from ebaysdk.shopping import Connection
s = Connection(config_file='./ebay.yaml', siteid='EBAY-GB',https=True,warnings=True,debug=True)
xml="""
<ItemID>SOMEITEMID</ItemID>
"""
r = s.execute("GetSingleItem", data=xml)
as well as requests directly:
import requests
headers = {
"X-EBAY-API-IAF-TOKEN":"YOURIAFTOKEN"
}
url = "https://open.api.ebay.com/shopping?callname=GetSingleItem&version=1199&ItemID=SOMEITEMID"
r = requests.Request(method="GET", headers=headers, url=url)
pr = r.prepare()
ses = requests.Session()
res = ses.send(pr)
print(res.content)
as well as requests directly 2:
import requests
headers = {
"X-EBAY-API-VERSION": "1199",
"X-EBAY-API-SITE-ID": "EBAY-GB",
"X-EBAY-API-REQUEST-ENCODING": "XML",
"Content-Type": "text/xml",
"X-EBAY-API-CALL-NAME": "GetSingleItem",
"X-EBAY-API-IAF-TOKEN":"YOURIAFTOKEN"
}
xml="""<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<GetSingleItemRequest xmlns=\"urnapis:eBLBaseComponents\">
<ItemID>SOMEITEMID</ItemID>
</GetSingleItemRequest>
"""
url = "https://open.api.ebay.com/shopping"
r = requests.Request(method="POST", headers=headers, data=xml.encode("UTF-8"), url=url)
pr = r.prepare()
ses = requests.Session()
res = ses.send(pr)
print(res.content)
python - ebaysdk - Shopping API, Token not found, yet included in YAML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2023 05:29 PM
If this is the instruction you are trying:
s = Connection(config_file=os.environ.get('EBAY_YAML'))
That is attempting to load something set to an environment variable of your host OS (differing depending on the OS you are using, you would need to figure out how to load the file contents to that variable prior to that line).
You could instead try to load the file directly:
s = Connection(config_file="./ebay.yaml")
the above being a relative path to where your python is working from.
you can also look at the config.values on the s object to see what has been loaded
s.config.values
or
print(s.config.values)
python - ebaysdk - Shopping API, Token not found, yet included in YAML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2023 04:06 PM
@five_notch_trading_post Thanks for the reply!
I'm constructing the call as per the ebaysdk Shopping class:
python - ebaysdk - Shopping API, Token not found, yet included in YAML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2023 05:36 PM
When I hard code the iaf token in the headers of the shopping __init__.py file (I know, not the best practice) the call works and returns data!
The __init__ file doesn't pick up the iaf token correctly from the yaml file.
I can use this: s.config.values and it returns the variables, including the iaf token from the yaml file. But the __init__ file doesn't pick it up.
Interesting. I will highlight this in the git hub issues tab for the ebaysdk repo.
python - ebaysdk - Shopping API, Token not found, yet included in YAML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 10:21 AM
hmmm,
api = Shopping(config_file='./ebay.yaml', siteid='EBAY-GB',https=True,warnings=True,debug=True)
works fine for me.
Are there any typos in iaf_token: in the yaml file? such as iaf-token? It will set a variable for anything listed in the yaml, used or not, even if it is incorrect. s.request.headers is another place to look to verify. Could also be something in how things are imported.
These are all working for me:
sdk import
from ebaysdk.shopping import Connection
s = Connection(config_file='./ebay.yaml', siteid='EBAY-GB',https=True,warnings=True,debug=True)
xml="""
<ItemID>SOMEITEMID</ItemID>
"""
r = s.execute("GetSingleItem", data=xml)
as well as requests directly:
import requests
headers = {
"X-EBAY-API-IAF-TOKEN":"YOURIAFTOKEN"
}
url = "https://open.api.ebay.com/shopping?callname=GetSingleItem&version=1199&ItemID=SOMEITEMID"
r = requests.Request(method="GET", headers=headers, url=url)
pr = r.prepare()
ses = requests.Session()
res = ses.send(pr)
print(res.content)
as well as requests directly 2:
import requests
headers = {
"X-EBAY-API-VERSION": "1199",
"X-EBAY-API-SITE-ID": "EBAY-GB",
"X-EBAY-API-REQUEST-ENCODING": "XML",
"Content-Type": "text/xml",
"X-EBAY-API-CALL-NAME": "GetSingleItem",
"X-EBAY-API-IAF-TOKEN":"YOURIAFTOKEN"
}
xml="""<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<GetSingleItemRequest xmlns=\"urnapis:eBLBaseComponents\">
<ItemID>SOMEITEMID</ItemID>
</GetSingleItemRequest>
"""
url = "https://open.api.ebay.com/shopping"
r = requests.Request(method="POST", headers=headers, data=xml.encode("UTF-8"), url=url)
pr = r.prepare()
ses = requests.Session()
res = ses.send(pr)
print(res.content)
python - ebaysdk - Shopping API, Token not found, yet included in YAML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2023 02:00 PM
I reverted the changes to the __init__ file of the shopping API class, and now it works... I really don't know how or why but it works.
I had no typos before, it just was giving me that token error. weird. I might have been doing something wrong but don't know what.
It works now. Thanks, @five_notch_trading_post for the time in assisting here.
