post - 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);
解决方案
好吧,我们无法确定您遇到的问题,但大多数时候我遇到此问题是因为缺少参数或在某些参数(如FeedType
.
我在程序中打印我的规范化字符串,并将其与String to Sign
mws-scratchpad 的请求详细信息进行比较。
推荐阅读
- api - 如何确保 RESTful API 向后兼容?
- azure-devops - 从 Azure DevOps 经典管道执行 YAML 模板
- php - jquery datatable initComplete函数不起作用
- mysql - 在MySQL中按日期/时间排序时如何获取上一行/下一行?
- regex - 反转匹配的正则表达式模式
- javascript - 距离下一个生日的剩余时间javascript
- r - 在 tapply 函数中无法获取范围以产生结果
- python - 如何使用集合和节点修复无效语法?
- java - 在 catch 块中调用 void 方法并引发异常的方法的单元测试
- gcc - 在构建内核模块时设置包含路径