首页 > 解决方案 > POSTMAN - AMAZON MWS - SubmitFeed - 您为供稿传递的 Content-MD5 HTTP 标头不匹配

问题描述

我正在尝试使用SubmitFeed网络服务通过POSTMAN应用程序将产品上传到亚马逊。

我使用它测试了我的请求Amazon MWS Scratchpad并且它有效。但是,当我尝试从 执行相同的请求时POSTMAN,我收到ContentMD5DoesNotMatch错误。

我计算的 MD5 值和 MD5 值Amazon MWS Scratchpad是一样的。出于这个原因,我认为上传文件时存在一些问题。

我错过了什么?

这是文件.xml:

<?xml version="1.0" encoding="iso-8859-1"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
  <Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier>M_EXAMPLE_123456</MerchantIdentifier>
  </Header>
  <MessageType>Product</MessageType>
  <PurgeAndReplace>false</PurgeAndReplace>
  <Message>
    <MessageID>1</MessageID>
    <OperationType>Update</OperationType>
    <Product>
      <SKU>56789</SKU>
      <StandardProductID>
        <Type>ASIN</Type>
        <Value>B0EXAMPLEG</Value>
      </StandardProductID>
      <ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
      <DescriptionData>
        <Title>Example Product Title</Title>
        <Brand>Example Product Brand</Brand>
        <Description>This is an example product description.</Description>
        <BulletPoint>Example Bullet Point 1</BulletPoint>
        <BulletPoint>Example Bullet Point 2</BulletPoint>
        <MSRP currency="USD">25.19</MSRP>
        <Manufacturer>Example Product Manufacturer</Manufacturer>
        <ItemType>example-item-type</ItemType>
      </DescriptionData>
      <ProductData>
        <Health>
          <ProductType>
            <HealthMisc>
              <Ingredients>Example Ingredients</Ingredients>
              <Directions>Example Directions</Directions>
            </HealthMisc>
          </ProductType>
        </Health>
      </ProductData>
    </Product>
  </Message>
</AmazonEnvelope>

这是我的请求和响应的正文:

在此处输入图像描述

这是我的预请求脚本:

var HTTPVerb = "POST";
var ValueOfHostHeaderInLowercase = "https://mws-eu.amazonservices.com"; 
var HTTPRequestURI = "/";

var TimeStamp = encodeURIComponent(new Date().toISOString());

var ContentMD5Value = "7iiKpIWEgdex10Isb8Szrw=="; //I wrote it here hardcoded here, to be sure.

var CanonicalizedQueryString = 
"AWSAccessKeyId=" + "***" +
"&Action=" + "SubmitFeed" +
"&ContentMD5Value=" + encodeURIComponent(ContentMD5Value) +
"&FeedType=" + "_POST_PRODUCT_DATA_" +
"&MWSAuthToken=" + "***" +
"&MarketplaceIdList.Id.1=" + "***" +
"&Merchant=" + "***" +
"&PurgeAndReplace=" + "false" + 
"&SignatureMethod=" + "HmacSHA256" +
"&SignatureVersion=" + "2" +
"&Timestamp=" + TimeStamp +
"&Version=" + "2009-01-01";

var StringToSign = HTTPVerb + "\n" +
  "mws-eu.amazonservices.com" + "\n" +
  HTTPRequestURI + "\n" +
  CanonicalizedQueryString;

let hash = CryptoJS.HmacSHA256(StringToSign, '***');
let Signature = (CryptoJS.enc.Base64.stringify(hash));

var PostQueryString = 
"AWSAccessKeyId=" + "***" +
"&Action=" + "SubmitFeed" +
"&Merchant=" + "***" +
"&MWSAuthToken=" + "***" +
"&SignatureVersion=" + "2" +
"&Timestamp=" + TimeStamp +
"&Version=" + "2009-01-01" +
"&ContentMD5Value=" + encodeURIComponent(ContentMD5Value) +
"&Signature=" + encodeURIComponent(Signature) + 
"&SignatureMethod=" + "HmacSHA256" +
"&FeedType=" + "_POST_PRODUCT_DATA_" +
"&MarketplaceIdList.Id.1=" + "***" +
"&PurgeAndReplace=" + "false"
;

pm.environment.set('AmazonHost', ValueOfHostHeaderInLowercase + HTTPRequestURI + '?' + PostQueryString);

标签: postfile-uploadpostmanamazon-mwsweb-api-testing

解决方案


好吧,我们无法确定您遇到的问题,但大多数时候我遇到此问题是因为缺少参数或在某些参数(如FeedType.

我在程序中打印我的规范化字符串,并将其与String to Signmws-scratchpad 的请求详细信息进行比较。


推荐阅读