ContentMD5Missing - 亚马逊web服务 [英] ContentMD5Missing - Amazon Webservice

查看:492
本文介绍了ContentMD5Missing - 亚马逊web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想张贴到饲料 - > SubmitFeed。

I'm trying to post to Feed -> SubmitFeed.

不过除了我收回是:

您必须通过一个Content-MD5 HTTP标头为你的饲料,所以我们可以   确保它不会破坏我们之前(例如从价格降到0)   处理它

you must pass a Content-MD5 HTTP header for your feed so we can be sure it was not corrupted (e.g. dropped a 0 from a price) before we process it

我不明白的是文档指出它是可选的,所以不能确定为什么我收到此。另外其实我穿过的东西。

What I don't understand is the documentation states that it is optional so unsure why I am receiving this. Plus I am actually passing something through.

XML

  <?xml version="1.0" encoding="UTF-8" ?> 
- <AmazonEnvelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" schemaLocation="amzn-base.xsd">
- <Header>
  <DocumentVersion>1</DocumentVersion> 
  <MerchantIdentifier>A1ddWU5JfffWJEddV9Xf668B</MerchantIdentifier> 
  </Header>
  <MessageType>Product</MessageType> 
  <PurgeAndReplace>false</PurgeAndReplace> 
- <Message>
  <MessageId>1</MessageId> 
  <OperationType>Update</OperationType> 
  </Message>
- <Product>
  <SKU>3308ff6-01</SKU> 
  </Product>
  </AmazonEnvelope>

我如何附上身体/头

How I attach the Body/Header

    var request = Helper.CreateWebRequest(xmlRequest.Config, genericparameters, signatureHelpers);

    request.Headers.Add("x-amazon-user-agent", amazonHostAgent);
    request.Method = "POST";
    request.ContentType = amazonConfig.ContentType;
    request.Timeout = 50000;

    Helper.AddXmlDocumentToRequest(xmlRequest.XmlDocument.InnerXml, request);

    public static void AddXmlDocumentToRequest(string xmlDocument, WebRequest request)
    {
        var bytes = Encoding.ASCII.GetBytes(xmlDocument);
        request.ContentLength = bytes.Length;
        var requestStream = request.GetRequestStream();

        request.Headers.Add("Content-MD5", GetMd5HashFromStream(bytes));

        requestStream.Write(bytes, 0, bytes.Length);
        requestStream.Close();
    }

    public static string GetMd5HashFromStream(byte[] bytes)
    {
        using (var md5 = MD5.Create())
        {
            var hash = md5.ComputeHash(bytes);
            return Convert.ToBase64String(hash);
        }
    }

在请求时,我钻到头我有以下几点:

Within the request when I drill down to Headers I have the following:

{x-amazon-user-agent: MWSApplication/1.0 (Language=c#)
Content-Type: text/xml
Host: mws.amazonservices.co.uk
Content-Length: 478
Expect: 100-continue
Content-MD5: 1xLxj5Y+WVsAVR9BbQfzQA==

}

当我通过暂存器运行XML返回相同的内容-MD5:1xLxj5Y + WVsAVR9BbQfzQA ==

When I run the xml through scratchpad it returns the same Content-MD5: 1xLxj5Y+WVsAVR9BbQfzQA==

我是不是做错了什么?

谢谢

克莱尔

推荐答案

这可能不是每个人的答案却是我,如果它可以帮助另外一个人,我会很高兴: - )

This might not be the answer for everyone however it was for me and if it helps one other person I will be happy :-)

我是非常愚蠢的,增加了头部流后,这是不是你应该做的。

Me being very stupid, added the header after the streaming, this is not what you should be doing.

  1. 创建网址
  2. 添加标题等元素,即 request.ContentType
  3. 在流文件(的请求体),如果需要的话
  4. request.GetResponse。
  1. Create the URL
  2. Add headers and other elements i.e. request.ContentType
  3. Stream documents (body of request) if required
  4. request.GetResponse.

谢谢

克莱尔

这篇关于ContentMD5Missing - 亚马逊web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆