您好,我想使用 REST api。我使用这样的代码:
namespace test2
{
class Program
{
static void Main(string[] args)
{
TestRest t = new TestRest();
t.Run();
}
}
public class TestRest
{
public TestRest() { }
public async void Run()
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://community-league-of-legends.p.mashape.com/");
client.DefaultRequestHeaders.Add("X-Mashape-Authorization", "tcsgoutBcXP5Lu5L2jYBOu4qeXehseiH");
HttpResponseMessage response = await client.GetAsync("api/v1.0/euw/summoner/getSummonerByName/NICK_FROM_GAME");
JObject response2 = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()) as JObject;
foreach (KeyValuePair<string, JToken> j in response2)
{
Console.WriteLine("Key:{0} Value:{1}", j.Key, j.Value);
}
}
}
}
但是在调用方法时:
await client.getAsync("...
程序正在退出。请帮助我,它的简单控制台应用程序可以使用简单的 api,我无法管理这个:(
谢谢