【发布时间】:2020-10-25 19:33:11
【问题描述】:
我正在尝试使用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);
【问题讨论】:
标签: post file-upload postman amazon-mws web-api-testing