diff --git a/src/Models/Issue.cs b/src/Models/Issue.cs index dc6b2528..36a069ed 100644 --- a/src/Models/Issue.cs +++ b/src/Models/Issue.cs @@ -1,5 +1,6 @@ using System; using System.Reflection; +using System.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -7,7 +8,6 @@ using System.Text.Json.Serialization; using System.Net.Http; #else using System.Net; -using System.Text; #endif namespace SourceGit.Models { @@ -46,11 +46,9 @@ namespace SourceGit.Models { e.StackTrace); #if NET6_0_OR_GREATER - var req = new HttpClient(); - req.DefaultRequestHeaders.Add("Content-Type", "application/json"); - req.DefaultRequestHeaders.Add("charset", "UTF-8"); - req.Timeout = TimeSpan.FromSeconds(1); - req.PostAsync("https://gitee.com/api/v5/repos/sourcegit/issues", new StringContent(JsonSerializer.Serialize(issue))).Wait(); + var content = new StringContent(JsonSerializer.Serialize(issue), Encoding.UTF8, "application/json"); + var req = new HttpClient() { Timeout = TimeSpan.FromSeconds(1) }; + req.PostAsync("https://gitee.com/api/v5/repos/sourcegit/issues", content).Wait(); #else var req = WebRequest.CreateHttp("https://gitee.com/api/v5/repos/sourcegit/issues"); req.Method = "POST";