Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all,
I have to rename several hundreds of reload tasks. My first idea : an excel file with old and new name, a loop and an API Call to rename each task.
I read https://help.qlik.com/en-US/sense-developer/February2021/APIs/RepositoryServiceAPI/index.html
and wasn't able to find anything that would do the job.
Did someone manage to do it?
Best regards,
Simon
Hello @simonaubert
Here is a simple PowerShell sample on how to perform that. The /qrs/task endpoint is mainly to start/stop tasks.
To update details about the details, you would need to use the /qrs/reloadtask endpoint.
The below simple shows the bare minimum arguments you need to get this working. You would just need to rewrite it in the programming language you want to use and add a loop statement to do it in bulk.
Note: "ModifiedDate" can be any date in the future, Qlik Sense will update it to the current date when the request has been processed. This argument is compulsory for PUT requests. If the date is missing or in the past, it will throw an error 409.
$oldname='Reload License Monitor'
$newname = "My new name Test"
$hdrs = @{}
$hdrs.Add("X-Qlik-xrfkey","12345678qwertyui")
$hdrs.Add("X-Qlik-User","UserDirectory=DOMAIN;UserId=Administrator")
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My\" | Where {$_.Subject -like '*QlikClient*'}
#Fetch task id
$url = 'https://qlikserver1.domain.local:4242/qrs/reloadtask?xrfkey=12345678qwertyui&filter=name+eq+%27'+$oldname+'%27'
$resp = Invoke-RestMethod -Uri $url -Method Get -Headers $hdrs -Certificate $cert -ContentType 'application/json'
#Update task name
$url = 'https://qlikserver1.domain.local:4242/qrs/reloadtask/'+$resp.id+'?xrfkey=12345678qwertyui'
$body = '{"name":"'+$newname+'","modifiedDate":"2021-09-29T15:28:33.769Z"}'
Invoke-RestMethod -Uri $url -Method Put -Headers $hdrs -Certificate $cert -Body $body -ContentType 'application/json'
Hi @simonaubert, yes you can do this kind of tasks using the QRS API, more info here: https://help.qlik.com/en-US/sense-developer/February2021/Subsystems/RepositoryServiceAPI/Content/Sen...
But not from the Qlik Sense script, you have to use another platform like Javascript or Python.
JG
Hello @JuanGerardo
Thanks for the answer. I already use the QRS API in script to reload tasks from script 😉
(for your information, I posted the detailed procedure here https://community.qlik.com/t5/Integration-Extension-APIs/Reloading-task-from-script-authentication-w... )
I'm just struggling with the documentation, the first link I gave don't explain much and the help is not that helpful 😄
Maybe I will try that https://help.qlik.com/en-US/sense-developer/February2021/Subsystems/RepositoryServiceAPI/Content/Sen...
Best regards,
Simon
Hi @simonaubert, I was wrong, I thought you were using another API.
I have been using this QRS API with tasks to start, stop, check, etc. but not to update them. I think the endpoint you propose is the right one, but I agree with you that it is very difficult to be successful only with the documentation, you need lot of try and error...
Good luck,
JG
Hello @simonaubert
Here is a simple PowerShell sample on how to perform that. The /qrs/task endpoint is mainly to start/stop tasks.
To update details about the details, you would need to use the /qrs/reloadtask endpoint.
The below simple shows the bare minimum arguments you need to get this working. You would just need to rewrite it in the programming language you want to use and add a loop statement to do it in bulk.
Note: "ModifiedDate" can be any date in the future, Qlik Sense will update it to the current date when the request has been processed. This argument is compulsory for PUT requests. If the date is missing or in the past, it will throw an error 409.
$oldname='Reload License Monitor'
$newname = "My new name Test"
$hdrs = @{}
$hdrs.Add("X-Qlik-xrfkey","12345678qwertyui")
$hdrs.Add("X-Qlik-User","UserDirectory=DOMAIN;UserId=Administrator")
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My\" | Where {$_.Subject -like '*QlikClient*'}
#Fetch task id
$url = 'https://qlikserver1.domain.local:4242/qrs/reloadtask?xrfkey=12345678qwertyui&filter=name+eq+%27'+$oldname+'%27'
$resp = Invoke-RestMethod -Uri $url -Method Get -Headers $hdrs -Certificate $cert -ContentType 'application/json'
#Update task name
$url = 'https://qlikserver1.domain.local:4242/qrs/reloadtask/'+$resp.id+'?xrfkey=12345678qwertyui'
$body = '{"name":"'+$newname+'","modifiedDate":"2021-09-29T15:28:33.769Z"}'
Invoke-RestMethod -Uri $url -Method Put -Headers $hdrs -Certificate $cert -Body $body -ContentType 'application/json'
Hello @Damien_V
First of all, thanks a lot, that's cool. I tried it in the script but of course since it uses the PUT method, I can't make it work. So, let's go with Powershell 😉
Best regards,
Simon