Reputation: 83
I am trying to upload multiple tracking numbers to an Amazon order using MWS API in PHP but don't know what would be the XML request for this. Here is the XML I am using which ends up uploading the last tracking number.
$feed = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>XXX</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<AmazonOrderID>$orderId</AmazonOrderID>
<FulfillmentDate>$FulfillmentDate</FulfillmentDate>
<FulfillmentData>
<CarrierCode>$carrierCode</CarrierCode>
<ShipperTrackingNumber>'1Z7X887R0370783509'</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
<MessageID>2</MessageID>
<OrderFulfillment>
<AmazonOrderID>$orderId</AmazonOrderID>
<FulfillmentDate>$FulfillmentDate</FulfillmentDate>
<FulfillmentData>
<CarrierCode>$carrierCode</CarrierCode>
<ShipperTrackingNumber>'1Z7X887R0075127492'</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
<MessageID>3</MessageID>
<OrderFulfillment>
<AmazonOrderID>$orderId</AmazonOrderID>
<FulfillmentDate>$FulfillmentDate</FulfillmentDate>
<FulfillmentData>
<CarrierCode>$carrierCode</CarrierCode>
<ShipperTrackingNumber>'1Z7X887R0375972085'</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
EOD;
Any help is appreciated!
Upvotes: 3
Views: 1490
Reputation: 59
I realize this is an old post, but in case anyone else is looking and can't get the XML to work, I did ultimately find the answer for myself, which was to submit the feed as a flat file instead of XML. My solution was in C# and not PHP, but basically the FeedType has to be set to "POST_FLAT_FILE_FULFILLMENT_DATA"
request.FeedType = "_POST_FLAT_FILE_FULFILLMENT_DATA_";
instead of "POST_ORDER_FULFILLMENT_DATA" and then submit a tab-delimited text file in the format defined here (from their European site, but I use this in the United States marketplace):
https://sellercentral-europe.amazon.com/gp/help/external/help.html?itemID=13491
I tried repeatedly to get the XML to work with a few different variations and simply could not make it work. Amazon's documentation on this is terrible and doesn't describe how to format the XML for multiple tracking numbers. When I switched to the flat file feed, it worked right away. If anyone has had any luck with the XML version, I would be interested in seeing that. I had an open case with Amazon for quite a while trying to get this information from them and they kept insisting that I was asking them to write my code for me when really I just wanted guidance on how to format the XML correctly for their system. I suspect that there is no way to get two tracking numbers to work in and XML feed and that it only works with a flat file.
Upvotes: 0
Reputation: 68
Try the following XML. Hope it helps.
<?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>My Store</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<MerchantOrderID>1234567</MerchantOrderID>
<MerchantFulfillmentID>1234567</MerchantFulfillmentID>
<FulfillmentDate>2002-05-01T15:36:33-08:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>UPS</CarrierCode>
<ShippingMethod>Second Day</ShippingMethod>
<ShipperTrackingNumber>1Z7X887R0075127492</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<MerchantOrderItemID>11</MerchantOrderItemID>
<MerchantFulfillmentItemID>11</MerchantFulfillmentItemID>
<Quantity>2</Quantity>
</Item>
</OrderFulfillment>
</Message>
<Message>
<MessageID>2</MessageID>
<OrderFulfillment>
<MerchantOrderID>1234567</MerchantOrderID>
<MerchantFulfillmentID>1234567</MerchantFulfillmentID>
<FulfillmentDate>2002-05-01T15:36:33-08:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>UPS</CarrierCode>
<ShippingMethod>Second Day</ShippingMethod>
<ShipperTrackingNumber>1Z7X887R0075127492</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<MerchantOrderItemID>22</MerchantOrderItemID>
<MerchantFulfillmentItemID>22</MerchantFulfillmentItemID>
<Quantity>2</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
For more information about XSD, you can refer to Amazon order Fulfilment XSD
Upvotes: 1
Reputation: 11119
Looks like you're not properly opening your messages.
Try this:
</Message>
Add this --> <Message>
<MessageID>2</MessageID>
</Message>
Add this --> <Message>
<MessageID>3</MessageID>
Upvotes: 0