我的程序员伙伴们,我基本上有这个异步 Get() 方法可以成功读取 Json 数据,但是在定位到路由时 -> localhost:59185/api/encompass/data 我收到一条消息:
No HTTP resource was found that matches the request URL 'http://localhost:59185/api/encompass/data'.
</Message>
我非常希望它会返回我的 JSON,尤其是在调试代码时,它位于底部的“字符串 res”中
任何人都知道为什么它不返回 Json 甚至认为它坐在“res”中?
控制器:
[HttpGet, Route("encompass/data")]
public async Task<string> Get(string Accesstoken)
{
string res = "";
using (var client = new HttpClient())
{
Accesstoken = Accesstoken.Substring(17, 28);
client.BaseAddress = new Uri("https://api.elliemae.com/");
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + Accesstoken);
var response = client.GetAsync("encompass/v1/loans/ea7c29a6-ee08-4816-99d2-fbcc7d15731d").Result;
using (HttpContent content = response.Content)
{
// ... Read the string.
Task<string> result = content.ReadAsStringAsync();
res = result.Result;
}
return res; //<- this is not returning the JSon thats sitting in here
}
}