【问题标题】:eBay API ItemCompatibility XML InputeBay API ItemCompatibility XML 输入
【发布时间】:2017-09-11 16:52:48
【问题描述】:

我正在使用 eBay API 和 python ebaysdk 模块。在我的 AddFixedPriceItem 请求发布新项目列表中,我想使用 Item.ItemCompatibility (在 ebayMotors 类别中使用我的生产密钥)但由于某种原因它只是不起作用。

根据在线文档,这是所需的 xml 输入:

 <ItemCompatibilityList> ItemCompatibilityListType
  <Compatibility> ItemCompatibilityType
    <CompatibilityNotes> string </CompatibilityNotes>
    <NameValueList> NameValueListType
      <Name> string </Name>
      <Value> string </Value>
      <!-- ... more Value values allowed here ... -->
    </NameValueList>
    <!-- ... more NameValueList nodes allowed here ... -->
  </Compatibility>
  <!-- ... more Compatibility nodes allowed here ... -->
</ItemCompatibilityList>

我可能有 15 或 20 种不同的方式来重新安排我的输入以向 ebay 提供他们想要的东西,但它们似乎都不起作用。这是我在请求中使用的最新代码:

    api_request = {
        'Item': {
            'Category': category,
            'Title': title,
            'ItemCompatibilityList': {
                'Compatibility': {
                    {'CompatibilityNotes': 'Fits for all trims and engines.'},
                    {'NameValueList': {'Name':'Year','Value':'2001'}},
                    {'NameValueList': {'Name':'Make','Value':'Honda'}},
                    {'NameValueList': {'Name':'Model','Value':'Accord'}}}}}}

api = trading(domain=DomainUrl, appid=Id_App, devid=Id_Dev, certid=Id_Cert, config_file=None)
api.execute('AddFixedPriceItem',api_request)

列表已发布并处于活动状态,并且所有其他信息都已正确发布,但看不到兼容性。它根本没有出现,而且我没有收到任何错误告诉我我做错了什么。

eBayMotors 的一个兼容性项目是:

[Honda, Accord, 2002]

但我想要的是几个兼容性项目:

[Honda, Accord, 2002], [Honda, Accord, 2003], [Honda, Accord, 2004]

等等。三四天前,我实际上一次将它作为一个单一的兼容性项目工作。但是我改变了我的代码以适应多年,并且在混合的某个地方我最终完全忘记了有效的代码。自从我失去它以来,我一直在无休止地工作,但我仍然无法弄清楚如何正确地做到这一点。我不确定数据结构是否设置不正确,是否还有其他我丢失的东西。任何帮助将不胜感激。

【问题讨论】:

    标签: python xml compatibility ebay-api


    【解决方案1】:

    在上面的代码中,字典键是重复的,这就是系统将覆盖 xml 中的值的原因。

    你应该发送字典列表。

    api_request = {
            'Item': {
            'Category': category,
            'Title': title,
            'ItemCompatibilityList': {
                'Compatibility': {
                    {'CompatibilityNotes': 'Fits for all trims and engines.'},
                    {'NameValueList'[{'Name':'Year','Value':'2001'},
                                     {'Name':'Make','Value':'Honda'},
                                     {'Name':'Model','Value':'Accord'}]
                    },                    
                    }
            }}}
    

    这可能会对你有所帮助。

    【讨论】:

    • 我刚才试了一下,我想我之前试过几次。无论出于何种原因,它似乎仍然根本不起作用。
    • 你能写出从dict生成的xml格式吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-15
    • 1970-01-01
    • 2017-10-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多