eBay 交易 API XML 响应

eBay Trading API XML Response

我正在尝试发出 getmyebayselling 请求,以便我可以跟踪当前列表的价格和数量。

按照文档和示例 here 我生成了一个令牌并尝试向产品发送请求 XML 以查看我当前的列表。

当前尝试:

endpoint = "https://api.ebay.com/ws/api.dll"
xml = """<?xml version="1.0" encoding="utf-8"?>
<GetMyeBaySellingRequest xmlns="urn:ebay:apis:eBLBaseComponents">
  <RequesterCredentials>
    <eBayAuthToken>AgAAAA*...full auth token here...wIAYMEFWl</eBayAuthToken>
  </RequesterCredentials>
  <Version>967</Version>
  <ActiveList>
    <Sort>TimeLeft</Sort>
    <Pagination>
      <EntriesPerPage>3</EntriesPerPage>
      <PageNumber>1</PageNumber>
    </Pagination>
  </ActiveList>
</GetMyeBaySellingRequest>"""
headers = {'Content-Type': 'application/xml'}
response = requests.post(endpoint, data=xml, headers=headers)
print response
print response.content

回复:

<?xml version="1.0" encoding="UTF-8" ?><GeteBayOfficialTimeResponse xmlns="urn:ebay:apis:eBLBaseComponents"><Timestamp>2017-04-17 13:01:25</Timestamp><Ack>Failure</Ack><Errors><ShortMessage>Unsupported API call.</ShortMessage><LongMessage>The API call "GeteBayOfficialTime" is invalid or not supported in this release.</LongMessage><ErrorCode>2</ErrorCode><SeverityCode>Error</SeverityCode><ErrorClassification>RequestError</ErrorClassification></Errors><Build>18007282</Build></GeteBayOfficialTimeResponse>

该回复的有用部分:

The API call "GeteBayOfficialTime" is invalid or not supported in this release.

我在这里使用他们自己的文档样本。我唯一能真正看到的 link 时间是 <Sort>TimeLeft</Sort>,这是一个延伸,但即使没有它,我也会得到相同的回应。

我正在研究不同的 Python 库,试图让 getmyebayselling 请求在没有太多文档的情况下工作。现在通过 eBay 本身的文档,我感觉自己已经死在水里了。如果有人能在正确的方向推动我,我将不胜感激。不确定接下来要尝试什么。

API 响应错误有点用处不大,但根据您共享的代码判断,您发出的请求缺少必需的 header 字段。更多详情 here

以下更改应该会为您指明正确的方向 -

headers = {
    'X-EBAY-API-COMPATIBILITY-LEVEL': '<compat_level>',
    'X-EBAY-API-CALL-NAME': '<api_call_name>',
    'X-EBAY-API-SITEID': '<api_siteid>',
    'Content-Type': 'application/xml'
}

我突然开始收到错误消息:

The API call "GeteBayOfficialTime" is invalid or not supported in this release.

但我没有打电话给 GeteBayOfficialTime!我遇到了问题,但错误消息具有误导性。

为确保您获得正确的 post headers 和内容,构建测试工具绝对有用:

ebay developer build test tool

经过几个小时的故障排除,我终于弄清楚了我的问题:我在查询字符串中传递了必需的 headers,而不是 http 请求 headers!用了一年多,还好好的,突然就不行了。

道德:无效的 "GeteBayOfficialTime" API 调用消息表明 http headers.

有问题