OA联调,需要utf8

This commit is contained in:
吴方海
2025-09-02 15:56:15 +08:00
parent 725b4d4de4
commit dd6d190c71
3 changed files with 12 additions and 11 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
namespace YLErp.Modules.ApiModule
{
@@ -83,7 +84,7 @@ namespace YLErp.Modules.ApiModule
public string PostJson(string apiPath, object postData, Action<HttpRequestMessage> requestHandle)
{
var str = JsonHelper.Serialize(postData) ?? string.Empty;
using (var content = new StringContent(str))
using (var content = new StringContent(str, Encoding.UTF8, "application/json"))
using (var request = new HttpRequestMessage()
{
Method = HttpMethod.Post,
@@ -93,7 +94,7 @@ namespace YLErp.Modules.ApiModule
{
request.Headers.Add("Accept-Encoding", "gzip");
requestHandle?.Invoke(request);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
// content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
LogFactory.GetLogger<HttpClientWrap>().Info($"url:{apiPath}\r\npostData:{str}\r\n{content.ToJson()}");
try
{