带有python-amazon-mws API的Amazon Feeds

问题描述 投票:2回答:1

我需要通过mws的feeds API访问我的库存。就在那时,我仅在python和czpython / python-amazon-mws存储库中工作。该文档非常细小,我很难处理。

access_key = MWS_ACCESS_KEYsecret_key = MWS_SECRET_KEYSeller_id = MWS_ACCOUNT_ID市场='A1PA6795UKMFR9'

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

Feeds.submit_feed(“ test.xlm”,“ Inventory.xsd”,市场)

如果我尝试此操作,将返回以下错误:

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个回答
0
投票

您需要这样称呼它:

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>
    """

确保用您的AmazonAccountId替换xxx。

© www.soinside.com 2019 - 2024. All rights reserved.