help needed with GetCategorySpecifics, sometimes it works, sometimes I just get a HTML answer instead of the XML, even with the same category etc.
So heres the code I use:
import requests
import xml.etree.ElementTree as ET
def get_category_specifics(app_id, category_id):
url = "https://api.ebay.com/ws/api.dll"
headers = {
"X-EBAY-API-SITEID": "77", # 77 steht für die deutsche eBay Seite (eBay.de)
"X-EBAY-API-CALL-NAME": "GetCategorySpecifics",
"X-EBAY-API-COMPATIBILITY-LEVEL": "967",
"X-EBAY-API-APP-ID": app_id, # Ihre eigene App-ID hier einsetzen
}
xml_request = f"""
<?xml version="1.0" encoding="utf-8"?>
<GetCategorySpecificsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>XXX</eBayAuthToken>
</RequesterCredentials>
<CategoryID>{category_id}</CategoryID>
</GetCategorySpecificsRequest>
"""
response = requests.post(url, headers=headers, data=xml_request)
response_content = ET.fromstring(response.content)
return response_content
def print_response_content(response_content):
print(f"Root element: {response_content.tag}")
for child in response_content:
if child.tag.endswith("Recommendations"):
for item in child:
if item.tag.endswith("NameRecommendation"):
for grandchild in item:
if grandchild.tag.endswith("Name"):
print(f"Item Specific Name: {grandchild.text}")
# Verwenden Sie Ihre eigene App-ID und Kategorie-ID hier
app_id = "XXX"
category_id = "8720"
response_content = get_category_specifics(app_id, category_id)
print_response_content(response_content)
Followed by other code to sort out the XML, this works if I get back the XML answer from the API.
This is my first post here, and Im not really that much into coding, so I hope your indulgent with me and my question.
If theres a better solution instead of the ebay SDK please let me know.
Richard
The code works from time to time. Same code different results. 90% the answer is a HTML file, 10% its the correct XML file with the data I wanted.
I've just been dealing with this exact issue for the last couple of weeks and actually found a resolution this week.
It seems to me the GetCategorySpecifics endpoint is non functioning. There are issues in the eBay developer forum going back to 2018. Main docs page for it seems to be gone also.
In the Commerce APIs of the new Restful API's set there is a getItemAspects endpoint which is from what I can tell the same thing as GetCategorySpecifics. I've been using that instead.
Docs page can be found here: https://developer.ebay.com/api-docs/commerce/taxonomy/resources/category_tree/methods/getItemAspectsForCategory