【问题标题】:Ebay product api consumer id errorEbay 产品 api 消费者 ID 错误
【发布时间】:2015-01-08 02:26:46
【问题描述】:

我正在尝试从 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 中没有提到consumerid,只提到了appid。

【问题讨论】:

  • 好吧,你的xml_request 无效xml,你用斜杠开始字符串
  • 从错误消息看来,它似乎需要一个 ConsumerID,从您的请求中我看不到正在传递一个。
  • @Mathemats 我编辑了帖子以澄清您的评论。

标签: python python-requests ebay-api


【解决方案1】:

上帝,我讨厌糟糕的 Api 文档。不同的 api 需要不同的 headers、urls 和 xmlns,这真的很烦人。无论如何,对于许多其他 api,您都缺少称为“X-EBAY-API-APP-NAME”的“X-EBAY-SOA-SECURITY-APPNAME”标头。它包含您的应用程序 ID。

【讨论】:

  • 你能提供一个工作示例/模板吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-03-30
  • 1970-01-01
  • 1970-01-01
  • 2011-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多