易趣交易API XML响应

问题描述 投票:2回答:2

我正在尝试制作一个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.

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

我正在尝试使用不同的Python库,试图让getmyebayselling请求在没有太多文档的情况下工作。现在,从eBay自己的文档开始,我感觉自己已经死了。如果有人能够朝着正确的方向推动我,我会很感激。不确定下一步该尝试什么。

python ebay ebay-api
2个回答
2
投票

API响应错误有点不太有用,但是根据您共享的代码判断,您发出的请求缺少必需的标头字段。更多细节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'
}

0
投票

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

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

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

为了确保您正确获得帖子标题和内容,构建测试工具绝对有用:

ebay developer build test tool

经过几个小时的故障排除后,我终于弄明白了我的问题:我在查询字符串中传递了所需的标头,而不是http请求标头!一年多了,它工作得很好,但突然间它停止了工作。

道德:无效的“GeteBayOfficialTime”API调用消息表明http标头存在问题。

© www.soinside.com 2019 - 2024. All rights reserved.