我需要将带有prametername的xmlData发布到webservice。我的代码是
HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
request.Method = "POST";
StreamWriter requestWriter = new StreamWriter(request.GetRequestStream());
requestWriter.Write(doc.InnerXml);
requestWriter.Close();
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
使用此功能,我可以传递数据,但缺少参数名称。那么如何将参数名称添加到postdata?
答案 0 :(得分:1)
您可以使用Multipart表单数据方法发送请求,例如,您可以在以下问题的答案中找到它的示例代码Multipart forms from C# client
您也可以尝试使用UrlEncode对发送文本进行编码,然后按以下格式发送数据“fieldName = urlEncodedData”