我试图将查询字符串传递到 BaseAddress 但它无法识别引号“?”。
引用破坏了 URI
首先我创建我的 BaseAddress
httpClient.BaseAddress = new Uri($"https://api.openweathermap.org/data/2.5/weather?appid={Key}/");
Run Code Online (Sandbox Code Playgroud)
然后我调用 GetAsync 方法,尝试添加另一个参数
using (var response = await ApiHelper.httpClient.GetAsync("&q=mexico"))....
Run Code Online (Sandbox Code Playgroud)
这是代码调用的 URI
https://api.openweathermap.org/data/2.5/&q=mexico
Run Code Online (Sandbox Code Playgroud)