易趣产品api消费者ID错误

时间:2015-01-08 02:26:46

标签: python python-requests ebay-api

我正在尝试从ebay Product API调用“getProductDetails”,但是我收到以下错误:

u'<?xml version=\'1.0\' encoding=\'UTF-8\'?><errorMessage xmlns="http://www.ebay.com/marketplace/marketplacecatalog/v1/services">
 <error><errorId>2000</errorId><domain>CoreRuntime</domain><severity>Error</severity><category>Request</category>
 <message>Service operation  is unknown</message><subdomain>Inbound_Meta_Data</subdomain><parameter name="Param1">
 </parameter></error><error><errorId>9</errorId><domain>Marketplace</domain><severity>Error</severity><category>Application
 </category><message>Invalid CONSUMER-ID specified</message><subdomain>MarketplaceCommon</subdomain><parameter name="CONSUMER_ID"/>
 </error></errorMessage>'

这是我正在使用的代码:

target_url = "http://svcs.ebay.com/services/marketplacecatalog/ProductService/v1"
xml_request = """\    
<?xml version="1.0" encoding="UTF-8"?>
<getProductDetailsRequest 
xmlns="http://www.ebay.com/marketplace/marketplacecatalog/v1/services">
   <productDetailsRequest>
      <productIdentifier>
         <productId>183439271</productId>
      </productIdentifier>
      <dataset>DisplayableProductDetails</dataset>
   </productDetailsRequest>
</getProductDetailsRequest> 
"""  

headers = {
    'OPERATION-NAME': 'getProductDetails',
    'SECURITY-APPNAME': APPID,
    } s

requests.post(target_url, data=xml_request, headers=headers).text

编辑:我没有Consumer-ID,我从ebay获得的密钥是:appid,devid,certid和token。在docs中没有提及消费者,只提到了appid。

1 个答案:

答案 0 :(得分:0)

上帝,我讨厌可怕的Api文档。不同的api需要不同的标题,网址和xmlns,它真的很烦人。无论如何,你错过了许多其他api的'X-EBAY-SOA-SECURITY-APPNAME'标题,它被称为'X-EBAY-API-APP-NAME'。它会接收您的应用ID。