- C# HttpWebRequest The underlying connection was closed: An unexpected error occurred on a send
- The underlying connection was closed: An unexpected error occurred on a send.--- NuGet
あなたはここに全体のコードを見つけることができます:それのhttps://github.com/te2020/GoEuroAPiClassLibrary/blob/master/GOEuroApi_Requests.cs
のみ関連する部分(何私は)思う:
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
httpClient.BaseAddress = new Uri("https://www.goeuro.com/");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/GoEuroAPI/rest/api/v5/searches");
request.Content = new StringContent(jsonString,
Encoding.UTF8,
"application/json");//CONTENT-TYPE header
私シオマネキはthisのように見え、それが動作します。
私はその要求を送信した後にERORを得る:
var response = await httpClient.SendAsync(request);
を私は何を逃したのですか?
また、FiddlerとPostmanからもエラーが発生しています。そのAPIは正常に実行されていますか? –
はい、数日前に同じロジックが働いていましたが、私のフィドラーはまだ動作しています –
私はあなたのために私のフィドラーの輸出をアップロードしました(作者=、見てくださいhttp://en.file-upload.net/download-12279292 /fiddlerExport_Composer.raz.html –