Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
We use the PowerShell module "Qlik-CLI" for years to start Qlik Sense tasks, wait for task execution end and check execution status.
Due to recurrent issues with out enterprise Security tools about the PowerShell module "Qlik-CLI" we need to switch to another technology and we are trying the Øystein Kolsrud's C#/.NET library "Qlik.Sense.RestClient" available on github and nuget. This library is not documented for our purpose : we can start a task with the method RestClient.Post but we are not able to get the response and get the execution ID needed to poll the execution status.
Could you please provide a solution to start a Qlik Sense task in .NET/C#, wait for execution end and check the status.
Thanks in advance for your answer.
I found the solution the day after my post but forgot to close this post.
Sorry about that.
Below the methods I use to start a task and poll the execution status :
private static String StartTask(RestClient restClient, String TaskId)
{
String task_start_response = restClient.Post("/qrs/task/" + TaskId + "/start/synchronous");
return JObject.Parse(task_start_response)["value"].Value<string>();
}
private static String GetExecutionStatus(RestClient restClient, String ExecutionId, String TaskId)
{
String ResultId;
try
{
String execution_session_response = restClient.Get("/qrs/executionSession/" + ExecutionId);
ResultId = JObject.Parse(execution_session_response)["executionResult"]["id"].Value<string>();
}
catch
{
String reloadtask_response = restClient.Get("/qrs/reloadTask/" + TaskId);
ResultId = JObject.Parse(reloadtask_response)["operational"]["lastExecutionResult"]["id"].Value<string>();
}
String execution_result_response = restClient.Get("/qrs/executionResult/" + ResultId);
return JObject.Parse(execution_result_response)["status"].Value<string>();
}
}
Best regards
I realized I posted in "QlikView Integrations". Sorry about that. Would it be possible to move this request to Qlik Sense ?
Hi @covering.
I moved this post to the Qlik Sense > Deployment & Management forum as you requested.
Best Regards
I found the solution the day after my post but forgot to close this post.
Sorry about that.
Below the methods I use to start a task and poll the execution status :
private static String StartTask(RestClient restClient, String TaskId)
{
String task_start_response = restClient.Post("/qrs/task/" + TaskId + "/start/synchronous");
return JObject.Parse(task_start_response)["value"].Value<string>();
}
private static String GetExecutionStatus(RestClient restClient, String ExecutionId, String TaskId)
{
String ResultId;
try
{
String execution_session_response = restClient.Get("/qrs/executionSession/" + ExecutionId);
ResultId = JObject.Parse(execution_session_response)["executionResult"]["id"].Value<string>();
}
catch
{
String reloadtask_response = restClient.Get("/qrs/reloadTask/" + TaskId);
ResultId = JObject.Parse(reloadtask_response)["operational"]["lastExecutionResult"]["id"].Value<string>();
}
String execution_result_response = restClient.Get("/qrs/executionResult/" + ResultId);
return JObject.Parse(execution_result_response)["status"].Value<string>();
}
}
Best regards