Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Sharip
Contributor
Contributor

C# get data from qlik

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);
}
}

0 Replies