如题,下面是请求部分的代码
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); request.Headers.Add("UUID:"+GetNetworkAdpaterID());//,Content-Type:data/gzencode and rsa public encrypt;charset=UTF-8 request.Headers.Add("ACCOUNT_TYPE:1 "); //request.Headers.Add("Content-Type: data/gzencode and rsa public encrypt;charset=UTF-8"); request.Method = "POST"; request.ContentType = "data/gzencode and rsa public encrypt;charset=UTF-8"; //request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; //request.ContentLength = postDataStr.Length; Stream myRequestStream = request.GetRequestStream(); StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("utf-8")); myStreamWriter.Write(postDataStr); myStreamWriter.Close(); #region 发送post请求到服务器并读取服务器返回信息 Stream responseStream; try { responseStream = request.GetResponse().GetResponseStream(); } catch (Exception e) { // log error Console.WriteLine( string.Format("POST操作发生异常:{0}", e.Message) ); throw e; } #endregion #region 读取服务器返回信息 string stringResponse = string.Empty; using (StreamReader responseReader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"))) { stringResponse = responseReader.ReadToEnd(); } responseStream.Close(); #endregion return stringResponse;
查看官方文档
http://dev2.baidu.com/docs.do?product=4#page=Message_return_code
报错12,估计下面设置有问题
request.Headers.Add("ACCOUNT_TYPE:1 ");
这句话没问题吧,不知道你又成功的例子没有,我这边遇到这个问题之后,没有解决,也不知道怎么去解决了。
请问下楼主我现在也是返回
\0\f\0\0\0\0\0\0,你是怎么解决的,麻烦告诉我下,太无奈了。QQ604605640
后面没做了,实在不知道怎么解决,也没人回答
@小林丶2013: 好吧。谢谢
@不疼不痒,不吵不闹: 这个就是个坑