Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys
My goal is fetch data from qlik's charts
1. I used HTTPWebRequest like bellow (but how can get data ?). i found that i should use location, and after connection i'l get data from hypercubes, like that:
// The default port number is 4747 but can be customized
var uri = new Uri("https://myserver:4242");
ILocation location = Location.FromUri(uri);
var x509 = new X509Certificate2(File.ReadAllBytes(@"C:\QlikCert\clinet_final.pfx"), "");
X509Certificate2Collection certificateCollection = new X509Certificate2Collection(x509);
location.AsDirectConnection(userDirectory: "domain", userId: "user", certificateCollection: certificateCollection);
Console.WriteLine("Step1");
//var location = ConnectToDesktop();
var allApps = OpenAllApps(location).ToArray();
if (allApps.Any())
{
UseAbstractStructureOnMasterObjects(allApps);
UseAbstractStructureOnMapLayers(allApps);
}
Console.WriteLine("Press enter to close.");
Console.ReadLine();
but i have an error(empty Certificate)
/// Code to fetch ID's
static async Task Main(string[] args)
{
// locate the client certificate and accept it as trusted
var SenseCert = new X509Certificate2(File.ReadAllBytes(@"C:\QlikCert\client_final.pfx"), "");
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Create the HTTP Request and add required headers and content in xrfkey
string xrfkey = "0123456789abcdef";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"https://myserver/single/?appid=9a819bbe-6094-44ea-9025-cf0379121f38&obj=ANRsbjb&opt=ctxmenu,currsel&..." + xrfkey);
/// i recieve Base64 img teg
request.Method = "GET";
request.Accept = "application/json";
request.Headers.Add("X-Qlik-xrfkey", xrfkey);
// Add the certificate to the request and provide the user to execute as
request.ClientCertificates.Add(SenseCert);
request.Headers.Add("X-Qlik-User", @"UserDirectory=internal;UserId=sa_repository");
// make the web request and return the content
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
//Console.WriteLine(new StreamReader(stream).ReadToEnd());
try
{
// Create a StreamReader
using (StreamReader reader = new StreamReader(stream))
{
string line;
// Read line by line
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
}
catch (Exception exp)
{
Console.WriteLine(exp.Message);
}
}