Error HttpWebRequest C #

1

I am making a request in a URL and trying to get the answer, I get the following error:

  

The underlying connection was closed: Unexpected error in a submission.

The point is that this statement worked normally.

Below the code:

var httpWebRequest = WebRequest.Create("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
    string json = "{ 'nl': { 'NL': '" + numeroLogico + "', 'CPF_CNPJ': '" + cnpj.Trim() + "', 'Bandeiras': [" + bandeiras + "], 'InativarBandeira': '" + inativarBandeiras + "', 'InativarLogico': '" + inativarLogico + "' } }";
    string jsonFinal = json.Replace("'", "\"");

    streamWriter.Write(json);
    streamWriter.Flush();
    streamWriter.Close();
}

var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

After requesting the response, I get the error. I do not know what to do, I've seen everything and nothing works.

    
asked by anonymous 23.06.2017 / 15:51

0 answers