这是Google Chrome服务的POST消息: 我想从C#发布此POST消息:
System.Net.WebRequest req =
System.Net.WebRequest.Create(@"http://www.ччч.ru/SystemService.asmx/VotingFoPhoto");
req.Method = "POST";
req.Timeout = 12000;
req.ContentType = "application/json; charset=UTF-8";
byte[] sentData = Encoding.GetEncoding(1251).GetBytes("photoId=E6A0327A&concursId=3");
req.ContentLength = sentData.Length;
System.IO.Stream sendStream = req.GetRequestStream();
sendStream.Write(sentData, 0, sentData.Length);
sendStream.Close();
req.GetResponse();
当我运行此代码时,我得到500服务器错误。请帮帮我。
答案 0 :(得分:3)
您已告知服务器content-type
为application/json
。但是您提供了application/x-www-urlencoded
格式的内容。
尝试提供JSON格式:
byte[] sentData =
Encoding.GetEncoding(1251).GetBytes("{'photoId':'E6A0327A';'concursId':3}");
或者尝试更改内容类型标题。