【问题标题】:Amazon Feeds with python-amazon-mws API使用 python-amazon-mws API 的 Amazon Feed
【发布时间】:2020-02-04 18:12:14
【问题描述】:

我需要通过 mws 的提要 API 访问我的库存。当时我只在 python 和 czpython/python-amazon-mws 存储库中工作。 文档非常薄,我很难使用。


access_key = MWS_ACCESS_KEY
secret_key = MWS_SECRET_KEY
seller_id = MWS_ACCOUNT_ID
市场 = 'A1PA6795UKMFR9'

Feeds = mws.Feeds(access_key, secret_key, Seller_id, region='DE')

Feeds.submit_feed("test.xlm","Inventory.xsd",marketplace)

如果我尝试这样做,它会返回以下错误:

TypeError: Unicode 对象必须在散列之前进行编码

我用于测试的目的是来自

的示例

https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/XML_Documentation_Intl.pdf

在第 41 页及以下。 XSD 文件是来自 Amazon 文档的新文件。

【问题讨论】:

    标签: python amazon amazon-mws


    【解决方案1】:

    你需要这样称呼它:

    Feeds.submit_feed(xml_request.encode('utf-8'),feed_type,marketplaces)
    

    这是一个适合您的工作示例

        marketplaces=['ATVPDKIKX0DER']
        feed_type='_POST_INVENTORY_AVAILABILITY_DATA_'
    
        xml_request="""
        <?xml version="1.0" encoding="utf-8"?>
    <AmazonEnvelope
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
        <Header>
            <DocumentVersion>1.01</DocumentVersion>
            <MerchantIdentifier>xxx</MerchantIdentifier>
        </Header>
        <MessageType>Inventory</MessageType>
        <PurgeAndReplace>false</PurgeAndReplace>
        <Message>
            <MessageID>1</MessageID>
            <OperationType>PartialUpdate</OperationType>
            <Inventory>
                <SKU>iI-0034-5a8g</SKU>
                <Quantity>13</Quantity>
            </Inventory>
        </Message>
        <Message>
            <MessageID>2</MessageID>
            <OperationType>PartialUpdate</OperationType>
            <Inventory>
                <SKU>hR-7530-6926</SKU>
                <Quantity>0</Quantity>
            </Inventory>
        </Message>      
    </AmazonEnvelope>
        """
    

    确保将 xxx 替换为您的 AmazonAccountId。

    【讨论】:

      猜你喜欢
      • 2016-12-22
      • 2012-12-22
      • 1970-01-01
      • 1970-01-01
      • 2015-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多