Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, I am trying to upload product through mws Submitfeed using C# VS2017.
I am facing this error.

XML Parsing Fatal Error at Line 23, Column 15: cvc-complex-type.4: Attribute 'unitOfMeasure' must appear on element 'Length'. cvc-complex-type.4: Attribute 'unitOfMeasure' must appear on element 'Length'

What I have tried:

XML Feed is this:


HTML
  1  <amazonenvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  2    
  3      <documentversion>1.01
  4      <merchantidentifier>A22RO79OS4OIEE
  5    
  6    <messagetype>Product
  7    <purgeandreplace>false
  8    <message>
  9      <messageid>1
 10      <operationtype>Update
 11      <product>
 12        <sku>BGS-2111 Black 8oz
 13        <standardproductid>
 14          <type>EAN
 15          <value>8971227095747
 16        
 17        <producttaxcode>A_GEN_NOTAX
 18        <descriptiondata>
 19          <title>BOXING GLOVES "SUPREME"
 20          <brand>Greenhill
 21          <description>Product description.
 22          <bulletpoint>MADE OF COWHIDE LEATHER
 23          <bulletpoint>For Training
 24          <msrp currency="EUR">25.19
 25          <manufacturer>Greenhill
 26          <itemtype>Gloves
 27        
 28        <productdata>
 29          <sports>
 30            <producttype>
 31              <sportsmisc>
 32                <value>Gloves
 33                <directions>Use Carefully








and C# Code is this:

C#
{
SubmitFeedRequest request = new SubmitFeedRequest();
                request.Merchant = merchantId;
                request.MWSAuthToken = "amzn.mws.82a5d9b7-0376-ed71-de61-b9ffdae2d926"; // Optional
                request.MarketplaceIdList = new IdList();
                request.MarketplaceIdList.Id = new List<string>(new string[] { marketplaceId });

                // MWS exclusively offers a streaming interface for uploading your feeds. This is because 
                // feed sizes can grow to the 1GB+ range - and as your business grows you could otherwise 
                // silently reach the feed size where your in-memory solution will no longer work, leaving you 
                // puzzled as to why a solution that worked for a long time suddenly stopped working though 
                // you made no changes. For the same reason, we strongly encourage you to generate your feeds to 
                // local disk then upload them directly from disk to MWS.

                request.FeedContent = File.Open("P1.xml", FileMode.Open, FileAccess.Read);

                //Calculating the MD5 hash value exhausts the stream, and therefore we must either reset the
                // position, or create another stream for the calculation.
                request.ContentMD5 = MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent);
                request.FeedContent.Position = 0;

                request.FeedType = "_POST_PRODUCT_DATA_";

                SubmitFeedSample.InvokeSubmitFeed(service, request);
}
Posted
Updated 15-Apr-20 7:16am
v2
Comments
Richard MacCutchan 15-Apr-20 7:59am    
Your XML is badly formed, lots of unclosed tags.

1 solution

This is how a product upload entry looks for me, with pricing uploaded separately. The <itemdimensions> tag has all of the unitOfMeasure components; what your particular error mentions. To 2nd what Mr. MacCutchan says, your xml tags are missing the enclosing brackets as well. I was going to simply post the ItemDimensions tag, but I hope seeing a single Message structure is of more use to you.
Edit: I should also mention that your c# code making the request does not appear to have any issues. In my case, I do
C#
feedSubmissionId = SubmitFeed.InvokeSubmitFeed(service, request);
because I store those ids, but I don't recall that being required.

HTML
<Message>
  <MessageID>10</MessageID>
  <OperationType>Update</OperationType>
  <Product>
    <SKU>007-D15206</SKU>
    <StandardProductID>
      <Type>UPC</Type>
      <Value>086876064216</Value>
    </StandardProductID>
    <ProductTaxCode>A_GEN_TAX</ProductTaxCode>
    <LaunchDate>2020-01-02T10:20:07.2366969-05:00</LaunchDate>
    <ItemPackageQuantity>1</ItemPackageQuantity>
    <NumberOfItems>1</NumberOfItems>
    <DescriptionData>
      <Title>Medium Super Stitch Wet Mop Head - 4 Ply Cotton, 5" Headband, White</Title>
      <Brand>Rubbermaid</Brand>
      <Description>Super Stitch® Wet Mop Head, medium, 4-ply cotton, 5" headband, looped end, for absorbing spills, white</Description>
      <ItemDimensions>
        <Length unitOfMeasure="IN">5.60</Length>
        <Width unitOfMeasure="IN">6.50</Width>
        <Height unitOfMeasure="IN">1.70</Height>
        <Weight unitOfMeasure="LB">1.10</Weight>
      </ItemDimensions>
      <Manufacturer>Rubbermaid</Manufacturer>
      <MfrPartNumber>FGD15206WH00</MfrPartNumber>
      <SearchTerms>rubbermaid, rubbermaid mop heads,  mop heads, restaurant mop heads, commercial mop heads</SearchTerms>
      <ItemType>rubbermaid-mop-heads, mop-heads</ItemType>
      <MerchantShippingGroupName>Default Amazon Template</MerchantShippingGroupName>
    </DescriptionData>
    <ProductData>
      <FoodServiceAndJanSan>
        <ProductType>
          <FoodServiceAndJanSan>
            <NumberOfItems>1</NumberOfItems>
          </FoodServiceAndJanSan>
        </ProductType>
      </FoodServiceAndJanSan>
    </ProductData>
  </Product>
</Message>
 
Share this answer
 
v2
Comments
megasoft house 21-Apr-20 0:58am    
Thank you very much, but now relationship(variations mentioned). Can you explain with some variations please.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900