2
votes

I Need access to my Inventory via the feeds API from mws. Right at the time i work only in python and the czpython/python-amazon-mws repository. The Documentation is very slim and i have trouble to work with.


access_key = MWS_ACCESS_KEY
secret_key = MWS_SECRET_KEY
seller_id = MWS_ACCOUNT_ID
marketplace = 'A1PA6795UKMFR9'

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

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

if i try this it return following Error:

TypeError: Unicode-objects must be encoded before hashing

i used for testing pruposes the Examples from the

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

at Page 41 and below. XSD Files are new from Amazon Documentation.

1

1 Answers

0
votes

you need to call it like this:

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

Here is a working sample for you

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

make sure to replace xxx with your AmazonAccountId.