2

我正在尝试HTTP POST从 Ebays Trading API 检索订单数据。我对此有些陌生-您可能会看到。我首先使用了他们的 API 测试工具,并通过生产环境成功获取了我的实际订单数据。

我复制了 HTTP 标头信息和 XML 请求部分,将其与我认为可以使其成为有效 HTTP Post 的文件一起放入文件中,然后使用 Curl 可执行文件 - 通过批处理文件调用。

这不起作用 - 所以我改用了一个更简单的请求 - GeteBayTime - 并得到了完全相同的结果。

我的批处理文件是...(全部为一行)

Curl -X POST --header "Content-Type:text/xml" -d @postfile https://api.ebay.com/ws/api.dll  > out.xml

邮编是...

POST / HTTP/1.1
Host: https://api.ebay.com/ws/api.dll
User-Agent: App v1.0
Connection: Keep Alive
Content-Length: 125
Content-Type: text/xml
X-EBAY-API-APP-ID:***-MyReal-APP-ID-here***
X-EBAY-API-VERSION:807  
X-EBAY-API-COMPATIBILITY-LEVEL:707
X-EBAY-API-SITE-ID:0
X-EBAY-API-CALL-NAME:GeteBayTime
X-EBAY-API-REQUEST-ENCODING:XML

<?xml version="1.0" encoding="utf-8"?>
<GeteBayTimeRequest xmlns="urn:ebay:apis:eBLBaseComponents">
</GeteBayTimeRequest>

结果(在 out.xml 中)是......

<?xml version="1.0" encoding="UTF-8"?>
-<GeteBayOfficialTimeResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2013-02-04 02:56:43</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>15743293</Build>
</GeteBayOfficialTimeResponse

谁能发现我的问题??

4

2 回答 2

1

只有请求正文必须在数据中 -

<?xml version="1.0" encoding="utf-8"?>
<GeteBayTimeRequest xmlns="urn:ebay:apis:eBLBaseComponents">
</GeteBayTimeRequest>

此值必须在标题中 -

X-EBAY-API-APP-ID:***-MyReal-APP-ID-here***
X-EBAY-API-VERSION:807  
X-EBAY-API-COMPATIBILITY-LEVEL:707
X-EBAY-API-SITE-ID:0
X-EBAY-API-CALL-NAME:GeteBayTime
X-EBAY-API-REQUEST-ENCODING:XML
于 2013-02-05T09:29:21.790 回答
1

我有解决方案 - 我花了一些时间找到正确的方法:

Curl -X POST -H "Content-type: text/xml" -H "X-EBAY-API-COMPATIBILITY-LEVEL:911" -H "X-EBAY-API-SITEID:3" -H "X-EBAY-API-CALL-NAME:GeteBayOfficialTime" -d @postfile.txt https://api.ebay.com/ws/api.dll

邮编:

<?xml version="1.0" encoding="utf-8"?>
<GeteBayOfficialTimeRequest xmlns="urn:ebay:apis:eBLBaseComponents">
    <RequesterCredentials>
        <eBayAuthToken>Your Token</eBayAuthToken>
    </RequesterCredentials>
</GeteBayOfficialTimeRequest>
于 2016-09-25T19:38:59.160 回答