当服务器以集成模式 5 (CAMPassport) 托管时,通过 C# 访问 TM1 Cognos REST API
Accessing TM1 Cognos REST API through C# , when server hosted with Integrated mode 5 (CAMPassport)
我正在尝试调用从 IBM TM1 Cognos 公开的 REST API。使用 HttpWebRequest object。当我尝试使用 base64(user:password:namespaceId).
通过授权 header 时获取 401
using (var client = new HttpClient())
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes("username:password:camnamespace");
var encodeData= System.Convert.ToBase64String(plainTextBytes);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("Authorization", "CAMNamespace "+ encodeData);
//GET Method
HttpResponseMessage response = await client.GetAsync("http://serveraddress/api/v1/Cubes");
if (response.IsSuccessStatusCode)
{
var det = await response.Content.ReadAsStringAsync();
}
else
{
Console.WriteLine("Internal server Error");
}
}
我认为您需要 payton: verify=False
中的内容来信任响应证书。
我正在尝试调用从 IBM TM1 Cognos 公开的 REST API。使用 HttpWebRequest object。当我尝试使用 base64(user:password:namespaceId).
通过授权 header 时获取 401using (var client = new HttpClient())
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes("username:password:camnamespace");
var encodeData= System.Convert.ToBase64String(plainTextBytes);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("Authorization", "CAMNamespace "+ encodeData);
//GET Method
HttpResponseMessage response = await client.GetAsync("http://serveraddress/api/v1/Cubes");
if (response.IsSuccessStatusCode)
{
var det = await response.Content.ReadAsStringAsync();
}
else
{
Console.WriteLine("Internal server Error");
}
}
我认为您需要 payton: verify=False
中的内容来信任响应证书。