我有一个HttpClient对象,我用它来对OpenFire进行休息调用。我有一个密钥,我正试图附加到呼叫的标题。这是如何正确完成的?我的尝试如下所示。使用client.DefaultRequestHeaders.Add("APIKEY", "theSecretKey")
HttpClient client = new HttpClient(handler);
client.BaseAddress = new Uri(Uri.UriSchemeHttps + "://" + domain);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));
client.DefaultRequestHeaders.Add("APIKEY", "theSecretKey");
HttpResponseMessage response = client.GetAsync(queryString).Result;
string stringResponse = response.Content.ReadAsStringAsync().Result;