Amazon Order Fulfillment with Multiple Packages for one Order _POST_ORDER_FULFILLMENT_DATA_ - amazon-mws

I have been dealing with a problem that pops up once a day. An order with multiple packages (fulfillmentdata,item). This is an order where the person may have ordered two different items and they were sent by the merchant in two different packages with different tracking numbers. Tends to be uncommon on amazon but very common in other systems.
I have tried multiple versions of the XML to try and make this work but to no success.
My first attempt:
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>XXXXXXXX</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<MerchantOrderID>55XXXX</MerchantOrderID>
<FulfillmentDate>2018-10-01T17:XX:XX-00:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>USPS</CarrierCode>
<ShippingMethod>First Class Parcel</ShippingMethod>
<ShipperTrackingNumber>940011590109XXXXXX</ShipperTrackingNumber>
</FulfillmentData>
<FulfillmentData>
<CarrierCode>USPS</CarrierCode>
<ShippingMethod>First Class Parcel</ShippingMethod>
<ShipperTrackingNumber>940011590109XXXXX</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>354178450XXXX</AmazonOrderItemCode>
<Quantity>1</Quantity>
</Item>
<Item>
<AmazonOrderItemCode>014909917XXXX</AmazonOrderItemCode>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
Next I tried to split it up into two different messages
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>XXXXXXXX</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<MerchantOrderID>554XXX</MerchantOrderID>
<FulfillmentDate>2018-10-01T17:XX:XX-00:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>USPS</CarrierCode>
<ShippingMethod>First Class Parcel</ShippingMethod>
<ShipperTrackingNumber>94001159010920XX</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>0149099174XXXX</AmazonOrderItemCode>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
<Message>
<MessageID>2</MessageID>
<OrderFulfillment>
<MerchantOrderID>554XXX</MerchantOrderID>
<FulfillmentDate>2018-10-01T17:XX:XX-00:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>USPS</CarrierCode>
<ShippingMethod>First Class Parcel</ShippingMethod>
<ShipperTrackingNumber>9400115901092029XXX</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>3541784506XXXX</AmazonOrderItemCode>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
With the second message I received the following error (for both message 1 and 2):
<MessageID>2</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>18028</ResultMessageCode>
<ResultDescription>The data you submitted is incomplete or invalid. For help fixing this, see http://sellercentral.amazon.com/gp/help/30721</ResultDescription>

Related

I can't delete empty containers in an xml document on SQL Server, such as "<Item />"

I started working for the first time and I don't know much yet, I've been suffering with this problem for two days.
I have a document of this type:
<Tables>
<dbo.ES_Connection_Modes>
<Item />
</dbo.ES_Connection_Modes>
<dbo.ES_Device_Categories>
<Item>
<LINK>1</LINK>
<F_Class>1</F_Class>
<N_Code>1</N_Code>
<B_Default>1</B_Default>
<B_Meter>1</B_Meter>
<B_Tranf>0</B_Tranf>
<B_Regist>0</B_Regist>
<B_Show_InMenu>1</B_Show_InMenu>
<N_Project>-1</N_Project>
<C_Const>EDC_Meter</C_Const>
</Item>
</dbo.ES_Device_Categories>
<dbo.ES_Indicating_Device_Types>
<Item />
</dbo.ES_Indicating_Device_Types>
<dbo.ES_Operating_Principles>
<Item />
</dbo.ES_Operating_Principles>
<dbo.ES_Precission_Classes>
<Item>
<LINK>7</LINK>
<N_Project>687783</N_Project>
<C_Name>2,0</C_Name>
<C_Const>EPC_20</C_Const>
</Item>
<Item>
<LINK>8</LINK>
<N_Project>687783</N_Project>
<C_Name>2,5</C_Name>
<C_Const>EPC_25</C_Const>
</Item>
</dbo.ES_Precission_Classes>
<dbo.ES_Granularity>
<Item />
</dbo.ES_Granularity>
</Tables>
I need to delete the empty item containers and the container containing it to get a document of the following type:
<Tables>
<dbo.ES_Device_Categories>
<Item>
<LINK>1</LINK>
<F_Class>1</F_Class>
<N_Code>1</N_Code>
<B_Default>1</B_Default>
<B_Meter>1</B_Meter>
<B_Tranf>0</B_Tranf>
<B_Regist>0</B_Regist>
<B_Show_InMenu>1</B_Show_InMenu>
<N_Project>-1</N_Project>
<C_Const>EDC_Meter</C_Const>
</Item>
</dbo.ES_Device_Categories>
<dbo.ES_Precission_Classes>
<Item>
<LINK>7</LINK>
<N_Project>687783</N_Project>
<C_Name>2,0</C_Name>
<C_Const>EPC_20</C_Const>
</Item>
<Item>
<LINK>8</LINK>
<N_Project>687783</N_Project>
<C_Name>2,5</C_Name>
<C_Const>EPC_25</C_Const>
</Item>
</dbo.ES_Precission_Classes>
</Tables>
I've tried a lot of things, deleted them, but here's the way I was hoping for, but I get an error:
SET #myDoc.modify('delete /Tables/*[contains(name(), "null")]');
Please try the following solution.
It is deleting 2nd level XML elements under the root (Tables) that have in turn Item elements without children.
SQL
DECLARE #myDoc XML =
N'<Tables>
<dbo.ES_Connection_Modes>
<Item/>
</dbo.ES_Connection_Modes>
<dbo.ES_Device_Categories>
<Item>
<LINK>1</LINK>
<F_Class>1</F_Class>
<N_Code>1</N_Code>
<B_Default>1</B_Default>
<B_Meter>1</B_Meter>
<B_Tranf>0</B_Tranf>
<B_Regist>0</B_Regist>
<B_Show_InMenu>1</B_Show_InMenu>
<N_Project>-1</N_Project>
<C_Const>EDC_Meter</C_Const>
</Item>
</dbo.ES_Device_Categories>
<dbo.ES_Indicating_Device_Types>
<Item/>
</dbo.ES_Indicating_Device_Types>
<dbo.ES_Operating_Principles>
<Item/>
</dbo.ES_Operating_Principles>
<dbo.ES_Precission_Classes>
<Item>
<LINK>7</LINK>
<N_Project>687783</N_Project>
<C_Name>2,0</C_Name>
<C_Const>EPC_20</C_Const>
</Item>
<Item>
<LINK>8</LINK>
<N_Project>687783</N_Project>
<C_Name>2,5</C_Name>
<C_Const>EPC_25</C_Const>
</Item>
</dbo.ES_Precission_Classes>
<dbo.ES_Granularity>
<Item/>
</dbo.ES_Granularity>
</Tables>';
SET #myDoc.modify('delete /Tables/*[not(Item/*)]');
-- test
SELECT #myDoc;

Modify a portion of an XML with key/value structure

I need to write a SQL Server query to change the values of the following example XML, each one should have a different new value:
Example:
From
<Item>
<key>RabbitMQConnection</key>
<value Tr="PropertyBag">
<Item>
<key>Encoding</key>
<value>65001</value>
</Item>
<Item>
<key>HostName</key>
<value>TESTHOST</value>
</Item>
<Item>
<key>UserName</key>
<value>USER</value>
</Item>
<Item>
<key>Password</key>
<value>PASS</value>
</Item>
<Item>
<key>QueueName</key>
<value>TESTQUEUE</value>
</Item>
<Item>
<key>VirtualHost</key>
<value>TESTVHOST</value>
</Item>
</value>
</Item>
<Item>
to
<Item>
<key>RabbitMQConnection</key>
<value Tr="PropertyBag">
<Item>
<key>Encoding</key>
<value>65001</value>
</Item>
<Item>
<key>HostName</key>
<value>TESTHOST22</value>
</Item>
<Item>
<key>UserName</key>
<value>USER222</value>
</Item>
<Item>
<key>Password</key>
<value>PASS22</value>
</Item>
<Item>
<key>QueueName</key>
<value>TESTQUEUE22</value>
</Item>
<Item>
<key>VirtualHost</key>
<value>TESTVHOST22</value>
</Item>
</value>
</Item>
<Item>
I'm really struggling with xpath language, can I get some help please?
Many thanks!
Please try the following.
You can modify the rest of the XML elements one by one by using the same approach.
SQL
DECLARE #xml XML =
N'<Item>
<key>RabbitMQConnection</key>
<value Tr="PropertyBag">
<Item>
<key>Encoding</key>
<value>65001</value>
</Item>
<Item>
<key>HostName</key>
<value>TESTHOST</value>
</Item>
<Item>
<key>UserName</key>
<value>USER</value>
</Item>
<Item>
<key>Password</key>
<value>PASS</value>
</Item>
<Item>
<key>QueueName</key>
<value>TESTQUEUE</value>
</Item>
<Item>
<key>VirtualHost</key>
<value>TESTVHOST</value>
</Item>
</value>
</Item>';
DECLARE #HostName NVARCHAR(30) = 'NewTESTHOST';
SET #xml.modify('replace value of (/Item/value/Item[key="HostName"]/value/text())[1]
with (sql:variable("#HostName"))' );
-- test
SELECT #xml;

How to extract values from a xml request body with values in an array in wiremock

I am trying to extract line-item value from the below request body into my response in wiremock.
Request:
**<request>
<lineItem>
<item>
<name> name </name>
<quantity> 12 </quantity>
<type>type</type>
</item>
</ lineItem>
<lineItem>
<item>
<name> name2 </name>
<quantity> 10 </quantity>
<type>type2</type>
</item>
</ lineItem>
</request>**
Expected Response:
**<response>
<lineItem>
<item>
<name> name </name>
<quantity> 12 </quantity>
<type>type</type>
</item>
</ lineItem>
<lineItem>
<item>
<name> name2 </name>
<quantity> 10 </quantity>
<type>type2</type>
</item>
</ lineItem>
</response>**
I tried something like this:
<response>
{{#each (xPath request.body '/lineItem/item ') as |element| }}
<lineItem>
<item>
<quantity> (xPath request.body '//lineItem/item/quantity/text()'}}</quantity>
</item>
</ lineItem>
</response>
but for 2 different lineItem in request (as given above), I got 3 lineItem values in response and always getting the first item values in all the 3 lineItems:
Response I got:
**<response>
<lineItem>
<item>
<quantity> 12 </quantity>
</item>
</ lineItem>
<lineItem>
<item>
<quantity> 12 </quantity>
</item>
</ lineItem>
<lineItem>
<item>
<quantity> 12 </quantity>
</item>
</ lineItem>
</response>**
Can someone help me with this scenario?

MWS submit feed returns InputDataError

I have implemented submit feed API for _POST_ORDER_FULFILLMENT_DATA_ and get feedsubmission result. it returns InputDataError.
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>A1OLX7E3BCNOP2</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<MerchantOrderID>114-7129872-3010653</MerchantOrderID>
<MerchantFulfillmentID>5e79aa3205f4f</MerchantFulfillmentID>
<FulfillmentDate>2020-03-06T09:00:00Z</FulfillmentDate>
<FulfillmentData>
<CarrierCode>USPS</CarrierCode>
<ShippingMethod>First Class</ShippingMethod>
<ShipperTrackingNumber>9405511298370995607859</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<MerchantOrderItemID>60227359610258</MerchantOrderItemID>
<MerchantFulfillmentItemID>item_5e79aa3205f4f</MerchantFulfillmentItemID>
<Quantity>1</Quantity>
<Transparencycode>AZ:SHGNCW8HKBBB8O4WZKYSHN7GYI</Transparencycode>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
Response:
<?xml version="1.0"?>
<ErrorResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">
<Error>
<Type>Sender</Type>
<Code>InputDataError</Code>
<Message>InputDataError</Message>
<Detail />
</Error>
<RequestID>7d4ebf9a-6cb1-4b45-9191-0a00c268982a</RequestID>
</ErrorResponse>
Can anyone help me for this issue?
In my past experience, MWS is very picky about capitalization (and spelling). Check TransparencyCode. You don't have the "c" capitalized. According to the XSD, it is. Make sure everything matches.
https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_4_1/OrderFulfillment.xsd

Amazon MWS XML how to specify shipping template

Would appreciate some sample XML. I simply want to specify which shipping template should apply to any given product.
Amazon support pointed me to https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_4_1/Override.xsd but I fail to see how to specify the shipping template.
I was hoping there was something simple that could be included as part of _POST_PRODUCT_PRICING_DATA_ such as
<shipping_template>template1</shipping_template>
but I don't see that.
Thanks!
You should use the _POST_PRODUCT_DATA_
Here is the xml example that works for amazon.com:
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion><MerchantIdentifier>XYZ</MerchantIdentifier></Header>
<MessageType>Product</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>PartialUpdate</OperationType>
<Product><SKU>YOURSKUNAME</SKU>
<DescriptionData>
<Title>Sometitle</Title><MerchantShippingGroupName>SHIPPINGTEMPLATENAME</MerchantShippingGroupName></DescriptionData>
</Product>
</Message>
</AmazonEnvelope>
Unfortunately it looks like the <Title> is mandatory even if you just want to change shipping template. If you want to change multiple skus at once just add more <Message> to the feed.
I Use this XML Feed for shipping orders and it works:
<?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>MERCHANT_IDENTIFIER</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>MESSAGE_ID2</MessageID>
<OrderFulfillment>
<AmazonOrderID>123-1234567-1234567</AmazonOrderID>
<FulfillmentDate>SHIP_DATE</FulfillmentDate> //$ship_date = date("c");
<FulfillmentData>
<CarrierCode>Royal Mail</CarrierCode>
</FulfillmentData>
</OrderFulfillment>
</Message>
<Message>
<MessageID>MESSAGE_ID2</MessageID>
<OrderFulfillment>
<AmazonOrderID>321-7654321-7654321</AmazonOrderID>
<FulfillmentDate>SHIP_DATE</FulfillmentDate> //$ship_date = date("c");
<FulfillmentData>
<CarrierCode>Royal Mail</CarrierCode>
</FulfillmentData>
</OrderFulfillment>
</Message>
.
.
.
</AmazonEnvelope>
$parameters = array(
'Merchant' => $MERCHANT_ID,
'MarketplaceIdList' => $marketplaceIdArray,
'FeedType' => '_POST_ORDER_FULFILLMENT_DATA_',
'FeedContent' => $feedHandle,
'PurgeAndReplace' => false, //Leave this PurgeAndReplace to false so that it want replace whole product in amazon inventory
'ContentMd5' => base64_encode(md5(stream_get_contents($feedHandle), true))
);
rewind($feedHandle);
$request = new MarketplaceWebService_Model_SubmitFeedRequest($parameters);
$return_feed = invokeSubmitFeed($service, $request);
fclose($feedHandle);

Resources