gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
使用c# HttpClient 调用https://uj1qee.laf.run/claude-chat,post,参数question
- User
使用c# HttpClient 调用https://uj1qee.laf.run/claude-chat,post,参数question
- Assistant
下面是使用C# HttpClient调用HTTPS接口的示例代码:
using System; using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main(string[] args) { using (HttpClient client = new HttpClient()) { try { // 设置请求的URL string url = "https://uj1qee.laf.run/claude-chat"; // 创建请求参数 var question = new { question = "Your question here" }; // 发送POST请求并获取响应 HttpResponseMessage response = await client.PostAsJsonAsync(url, question); response.EnsureSuccessStatusCode(); // 获取响应的内容 string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } catch (HttpRequestException e) { Console.WriteLine($"请求失败: {e.Message}"); } } } }请将"Your question here"替换为你要发送的具体问题。这段代码会将问题以JSON格式作为请求体发送给指定的URL,并获取响应的内容。