我正在尝试进行Web申请,并且我无法使用POST,因为de Web Service期望GET来提供参数。但是我收到以下协议违规错误:
var streamWriter = new StreamWriter(wReq.GetRequestStream()
有人可以帮我吗?
WebRequest wReq = HttpWebRequest.Create(InfoBipLogURL);
wReq.Method = "GET";
wReq.Headers["Authorization"] = "Basic " + TokenAutorizacaoInfoBip;
wReq.Headers["Cookie"] = Cookie_Aut;
wReq.ContentType = "application/json";
using (var streamWriter = new StreamWriter(wReq.GetRequestStream()))
{
streamWriter.Write(objLog.ToJsonString());
streamWriter.Flush();
streamWriter.Close();
}
using (var resposta = wReq.GetResponse() as HttpWebResponse)
{
var streamDados = resposta.GetResponseStream();
StreamReader reader = new StreamReader(streamDados);
object objResponse = reader.ReadToEnd();
var retornoLog = JsonConvert.DeserializeObject<RetornoLog>(objResponse.ToString());
streamDados.Close();
resposta.Close();
return retornoLog;
}