Content-Type httpClient使用c#获取响应

时间:2014-11-20 09:03:27

标签: c# windows-8.1

我需要使用以下标题从url获取响应:

HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("Content-Type", "application/json");
httpClient.DefaultRequestHeaders.Add("X-apiKey", App.API_Key);
string responseAsString = await httpClient.GetStringAsync("http://......./");

它在此行停止运行,没有任何responseAsString值:

 httpClient.DefaultRequestHeaders.Add("Content-Type", "application/json");

0 个答案:

没有答案