Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I have a requirement where I would like to get task ID by passing the task name using QS API endpoint from C#.net code.
Is this something that can be done?
I tried below code which is giving me all the tasks but I want to pass a task name and get its specific task id.
var restClient = new RestClient(qliksenseurl);
var executeTask1 = $"/qrs/task/";
var rsp1 = await restClient.GetAsync<JArray>(executeTask1);
Hi @Manish,
We are here again 🙂
Use this code and you should be fine. I used as a filter a task name called 'Temp Test':
try
{
Console.WriteLine("Starting Qlik Sense Connection");
var restClient = new RestClient(qlikSenseUrl);
restClient.AsNtlmUserViaProxy(new NetworkCredential(userName, securePassword, userDomain), certificateValidation: false);
Console.WriteLine("Connection stabilished");
var getTaskURL = $"/qrs/task?filter=name eq 'Temp Test'";
foreach (var task in await restClient.GetAsync<JArray>(getTaskURL))
{
Console.WriteLine(task["id"]);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
Hi @Manish,
We are here again 🙂
Use this code and you should be fine. I used as a filter a task name called 'Temp Test':
try
{
Console.WriteLine("Starting Qlik Sense Connection");
var restClient = new RestClient(qlikSenseUrl);
restClient.AsNtlmUserViaProxy(new NetworkCredential(userName, securePassword, userDomain), certificateValidation: false);
Console.WriteLine("Connection stabilished");
var getTaskURL = $"/qrs/task?filter=name eq 'Temp Test'";
foreach (var task in await restClient.GetAsync<JArray>(getTaskURL))
{
Console.WriteLine(task["id"]);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
Hahah... Yes, I thought it is better to start a new discussion rather than using the old one.
Thanks @marksouzacosta It worked perfectly.
You might also want to have a look at this page describing filtering options:
https://help.qlik.com/en-US/sense-developer/May2024/Subsystems/RepositoryServiceAPI/Content/Sense_Re...
Thanks @Øystein_Kolsrud . It is helpful to know.
As a little trick,
There is a PowerShell binary module QlikSenseCLI. in recent versions of Qlik Sense this will be in you install directory \Tools\QlikSenseCLI
you can add the QlikSenseCLI.dll to you C# project, and use that to communicate with the QRS Apis.
bool TrustAllCertificates = true;
// you can authenticate in a variety of ways
//Current User Local system
client = QlikSenseCLI.QlikSense.Connect();
//QlikClient Certificate Auth
client = QlikSenseCLI.QlikSense.Connect(hostname, x509Cetificate, "Internal\\sa_api", TrustAllCertificates);
//Specified host Current User Auth
client = QlikSenseCLI.QlikSense.Connect(hostname,TrustAllCertificates);
//Specified host, specified credentials
client = QlikSenseCLI.QlikSense.Connect(hostname,networkCredentials,TrustAllCertificates);
var getTaskURL = $"/qrs/task?filter=name eq 'Temp Test'";
QlikSenseCLI.Model.TaskCondensed[] tasks = client.InvokeGet(getTaskURL);
var getTaskFullURL = $"/qrs/task/full?filter=name eq 'Temp Test'";
QlikSenseCLI.Model.Task[] tasksFull = client.InvokeGet(getTaskFullURL);