diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiChat/Impl/AzureRestChatService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiChat/Impl/AzureRestChatService.cs index 1d6328ae..502eae48 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiChat/Impl/AzureRestChatService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/AiChat/Impl/AzureRestChatService.cs @@ -55,10 +55,15 @@ public class AzureRestChatService : IChatService // 设置请求头 httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {_options.ApiKey}"); // 其他头信息如Content-Type在StringContent中设置 + + // 构造 POST 请求 + var request = new HttpRequestMessage(HttpMethod.Post, apiUrl); - var content = new StringContent(jsonBody, Encoding.UTF8, "application/json"); + // 设置请求内容(示例) + request.Content =new StringContent(jsonBody, Encoding.UTF8, "application/json"); + // 发送POST请求 - HttpResponseMessage response = await httpClient.PostAsync(apiUrl, content, cancellationToken); + HttpResponseMessage response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); // 确认响应成功 response.EnsureSuccessStatusCode();