我在 .Net 4.0 中并尝试使用 HttpClient。我读了一些文章说它在 4.0 中不再支持但您仍然可以使用它?我已经包含了System.Net.Http;
程序集,但它不允许我向HttpClient
. 知道如何解决这个问题吗?
我在错误发生的地方加粗了。
using (HttpClient http = new **HttpClient("{0}/v1/dm/labels/{1}.xml", MI_API_URL**))
{
http.**TransportSettings**.Credentials = new NetworkCredential(apiusername, apipassword);
List<KeyValuePair<string, string>> parms = new List<KeyValuePair<string, string>>();
parms.Add(new KeyValuePair<string, string>("Status", "Wiped"));
HttpResponseMessage response = http.**Get**(new Uri("devices.xml", UriKind.Relative), parms);
response.EnsureStatusIsSuccessful();
responseoutput = response.Content.ReadAsString();
xdoc.LoadXml(responseoutput);