I am using the Order Acknowledgment feed to cancel the order for Amazon. Below is the xml feed format that I am using to cancel the Amazon order.
I have successfully been able to submit this feed to MWS, but every time when I check the feed submission result it always gives this error
'The XML you submitted is ill-formed at the Amazon Envelope XML level
at (or near) line 1, column 485'.
I created the xml format according to this Selling on Amazon: Guide to XML.
<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_xxxxxx_108291953</MerchantIdentifier>
</Header>
<MessageType>OrderAcknowledgment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderAcknowledgement>
<AmazonOrderID>123-1234567-1234567</AmazonOrderID>
<StatusCode>Failure</StatusCode>
<CancelReason>BuyerCanceled</CancelReason>
</OrderAcknowledgment>
</Message>
</AmazonEnvelope>
Can any one help me what i am missing here in the xml format?
There are two problems with your XML code:
Amazon uses "OrderAcknowledgement", not "OrderAcknowledgment". While that choice may be debatable, the XSDs do not leave any room for a different spelling. (this applies to the MessageType and both opening and closing XML tag, your spelling is correct for the opening tag only)
CancelReason is only valid inside <Item> substructures.
The following XML validates:
<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_xxxxxx_108291953</MerchantIdentifier>
</Header>
<MessageType>OrderAcknowledgement</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderAcknowledgement>
<AmazonOrderID>123-1234567-1234567</AmazonOrderID>
<StatusCode>Failure</StatusCode>
<Item>
<AmazonOrderItemCode>12345678901234</AmazonOrderItemCode>
<CancelReason>BuyerCanceled</CancelReason>
</Item>
<Item>
<AmazonOrderItemCode>12345678901235</AmazonOrderItemCode>
<CancelReason>BuyerCanceled</CancelReason>
</Item>
<Item>
<AmazonOrderItemCode>12345678901237</AmazonOrderItemCode>
<CancelReason>BuyerCanceled</CancelReason>
</Item>
</OrderAcknowledgement>
</Message>
</AmazonEnvelope>
Related
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!
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
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>
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.
I have create xml for proudct image upload but it give me error
XML Parsing Error at Line 11, Column 128: cvc-complex-type.2.4.d: Invalid content was found starting with element 'ImageType'. No child element is expected at this point.
here my xml file
Please check where to change to solve the error
<?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>ASHAXSDLATFYG</MerchantIdentifier>
</Header>
<MessageType>ProductImage</MessageType><Message>
<MessageID>1</MessageID>
<ProductImage>
<SKU>BG4303</SKU>
<ImageType>Main</ImageType>
<ImageLocation>http://exmple.com/15203203915886PhotoC3551960-1.jpeg</ImageLocation>
<ImageType>PT1</ImageType>
<ImageLocation>http://exmple.com/15203203915886PhotoC3551960-1.jpeg</ImageLocation>
<ImageType>PT2</ImageType>
<ImageLocation>http://exmple.com/15203203915886PhotoC3551960-1.jpeg</ImageLocation>
</ProductImage>
</Message>
</AmazonEnvelope>
The following xml worked for me, not sure if its proper way or not. I am new to amazon mws as well.
<MessageType>ProductImage</MessageType>
<PurgeAndReplace>false</PurgeAndReplace>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<ProductImage>
<SKU>BG4303</SKU>
<ImageType>Main</ImageType>
<ImageLocation>http://exmple.com/15203203915886PhotoC3551960-1.jpeg</ImageLocation>
</ProductImage>
</Message>
<Message>
<MessageID>2</MessageID>
<OperationType>Update</OperationType>
<ProductImage>
<SKU>BG4303</SKU>
<ImageType>Swatch</ImageType>
<ImageLocation>http://exmple.com/15203203915886PhotoC3551960-1.jpeg</ImageLocation>
</ProductImage>
</Message>
Download the Amazon XSDs and validate using xmllint.
xmllint --schema {$schema} {$xmlFile} --noout
XSD List:
https://github.com/crazyfactory/amazon-xsd
I am trying to update shipping information through the feed API and here is my xml feed
<?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>Merchant id</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<MerchantOrderID>AmazonOrderId</MerchantOrderID>
<FulfillmentDate>2015-05-23T04:57:09+00:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>Fedex</CarrierCode>
<ShipperTrackingNumber>78066505</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<MerchantOrderItemID>OrderItemId</MerchantOrderItemID>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
When I submit the feed getting response as We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed. But both the order id and order item id is valid one.
In the sample feed provided by amazon I can see <MerchantFulfillmentID>1234567</MerchantFulfillmentID> and <MerchantFulfillmentItemID>1234567</MerchantFulfillmentItemID> but where can I find these ids.
As stated here Selling on Amazon Guide to XML:
You can send your own unique order and item identifiers
(MerchantOrderID and MerchantOrderItemID) rather than Amazon's order
and item identifiers, if you established your own in the
OrderAcknowledgement feed.
MerchantOrderID:
Optional seller supplied order ID. The first step is to establish the
MerchantOrderID in the acknowledgem ent feed. Amazon will map the
MerchantOrderID to the AmazonOrderID, and you can then use your own
order ID (MerchantOrderID) for subsequent feeds relating to that
order. See the base XSD for the definition.
MerchantFulfillmentID:
Seller supplied unique identifier for the shipment (not used by Amazon)
If you did not established your own ID´s in the OrderAcknowledgement feed, you can not use this fields in the Order Fulfillment feed.
Instead you have to speficy AmazonOrderID and Item.AmazonOrderItemCode. The AmazonOrderItemCode is an code for this specific product in this specific order. It has nothing todo with the famous ASIN or something.
Working example for an _POST_ORDER_FULFILLMENT_DATA_ feed would like like:
<AmazonEnvelope>
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_TESTSHOP_1337</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<AmazonOrderID>110-64133780-1337563</AmazonOrderID>
<FulfillmentDate>2015-11-02T13:02:14</FulfillmentDate>
<FulfillmentData>
<CarrierName>DHL</CarrierName>
<ShippingMethod>Paket</ShippingMethod>
<ShipperTrackingNumber>1337</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>033521337643</AmazonOrderItemCode>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
The XML I am submitting for customer refund 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>A24MUCS*****</MerchantIdentifier>
</Header>
<MessageType>OrderAdjustment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderAdjustment>
<AmazonOrderID>105-3616276-******</AmazonOrderID>
<AdjustedItem>
<AdjustmentReason>CustomerCancel</AdjustmentReason>
<ItemPriceAdjustments>
<Component>
<Type>Principal</Type>
<Amount currency="USD">0.09</Amount>
</Component>
<Component>
<Type>Shipping</Type>
<Amount currency="USD">4.87</Amount>
</Component>
</ItemPriceAdjustments>
</AdjustedItem>
</OrderAdjustment>
</Message>
</AmazonEnvelope>
On submitting the XML the error returned by Amazon is:
Error 5000:This is a malformed or invalid XML document.
Your XML does not seem malformed or invalid. However it is missing the AmazonOrderItemCode or MerchantOrderItemID which needs to be stated before AdjustmentReason, which is why it doesn't validate.
I am trying to cancel the order on the amazon, initially was having some of the format issues, now all the format issues are removed but feed result is keep showing one or more item is invalid. i am using the correct xml format to cancel the order and also the correct amazon order id and amazon order item id, both id are valid but the result keep showing the invalid item.
Order Acknowledgement Feed Format:
<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_xxxxx_108291953</MerchantIdentifier>
</Header>
<MessageType>OrderAcknowledgement</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderAcknowledgement>
<AmazonOrderID>111-1111111-7313343</AmazonOrderID>
<StatusCode>Failure</StatusCode>
<Item>
<AmazonOrderItemCode>232327843324</AmazonOrderItemCode>
<CancelReason>BuyerCanceled</CancelReason>
</Item>
</OrderAcknowledgement>
</Message>
</AmazonEnvelope>
Response On feed submission result: as i try to get the feed result it shows this error 'We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed.', below is the feed submission result.
<?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.02</DocumentVersion>
<MerchantIdentifier>M_xxxxx_108291953</MerchantIdentifier>
</Header>
<MessageType>ProcessingReport</MessageType>
<Message>
<MessageID>1</MessageID>
<ProcessingReport>
<DocumentTransactionID>7801114004</DocumentTransactionID>
<StatusCode>Complete</StatusCode>
<ProcessingSummary>
<MessagesProcessed>1</MessagesProcessed>
<MessagesSuccessful>0</MessagesSuccessful>
<MessagesWithError>1</MessagesWithError>
<MessagesWithWarning>0</MessagesWithWarning>
</ProcessingSummary>
<Result>
<MessageID>1</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>25</ResultMessageCode>
<ResultDescription>We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed.</ResultDescription>
</Result>
</ProcessingReport>
</Message>
</AmazonEnvelope>
Can any one one help me on this to make it work.
i am able to cancel the entire order in amazon.
xml i am using
<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>'.$storeDetails["merchantIdentifier"].'</MerchantIdentifier>
</Header>
<MessageType>OrderAcknowledgement</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderAcknowledgement>
<AmazonOrderID>'.$amazonOrderId.'</AmazonOrderID>
<StatusCode>Failure</StatusCode>
<Item>
<AmazonOrderItemCode>'.$item['store_product_code'].'</AmazonOrderItemCode>
<CancelReason>'.$reason.'</CancelReason>
</Item>
</OrderAcknowledgement>
</Message>
</AmazonEnvelope
====
Let me know if it helps.