在C#中为缓存调用添加密钥到标头

时间:2017-04-28 14:26:41

标签: c# asp.net web-services rest

我有一个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;

0 个答案:

没有答案