Qlik Community

Integration, Extension & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
cvalarcon
Contributor III
Contributor III

400 bad request when using Qlik-CLI

Hello all,

I am trying to query for all tasks with this command using Qlik-CLI,

I am able to connect successfully,

The command is as follows:

Get-QlikTask -filter TASK_11

This produces the following error message:

Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At C:\Program Files\WindowsPowerShell\Modules\Qlik-Cli\functions\core.ps1:66 char:23
+ $result = Invoke-RestMethod @paramInvokeRestMethod @params
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebE
xception
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand


Any ideas what I'm doing wrong?

Labels (1)
  • API

2 Solutions

Accepted Solutions
Levi_Turner
Employee
Employee

The Repository Service syntax (https://help.qlik.com/en-US/sense-developer/Subsystems/RepositoryServiceAPI/Content/Sense_Repository...) which Qlik-Cli-Windows leverages would be something like this:

Get-QlikTask -Filter "name eq 'Reload Operations Monitor'"

View solution in original post

cvalarcon
Contributor III
Contributor III
Author

Hi Levi now is ok . thank you  !!!

Now I have another challenge for you 😉

with this result (with -full parameter and the task name) I need to save this task id in a variable to be able to automate this task or several tasks . So the question is 

How can I get the task id in powershell ? because when you create a new task you don´t know the task ID at the beginning . In order to start the task you need  this as a parameter.    Thanks

View solution in original post

8 Replies
Levi_Turner
Employee
Employee

You're not using a proper filter syntax. What is "TASK_11"? A task name?

cvalarcon
Contributor III
Contributor III
Author

Hi Levi , "TASK_11"  is the task name , should be another parameter ? 

Thansk

Levi_Turner
Employee
Employee

The Repository Service syntax (https://help.qlik.com/en-US/sense-developer/Subsystems/RepositoryServiceAPI/Content/Sense_Repository...) which Qlik-Cli-Windows leverages would be something like this:

Get-QlikTask -Filter "name eq 'Reload Operations Monitor'"

cvalarcon
Contributor III
Contributor III
Author

Hi Levi now is ok . thank you  !!!

Now I have another challenge for you 😉

with this result (with -full parameter and the task name) I need to save this task id in a variable to be able to automate this task or several tasks . So the question is 

How can I get the task id in powershell ? because when you create a new task you don´t know the task ID at the beginning . In order to start the task you need  this as a parameter.    Thanks

Levi_Turner
Employee
Employee

Well, what information do you have?

In the QMC, you can expose the ID value for the task:

Levi_Turner_0-1647455910967.png

When using Qlik-Cli-Windows, you can use the Get-QlikTask function like above with an adjusted filter.

cvalarcon
Contributor III
Contributor III
Author

Hi  Levi, I konw this .

The idea is to automate a reload task from the scratch using QLIK-CLI (not QMC), so I need create a script to do this :

  1. First create an app 
  2. Create a task with this app 
  3. Start the task in order to reload the app 
  4. Copy this APP in folder for backup

I did all step except the (3) because when you create a task (allway using QLIK-CLI) you don´t know the new ID task (all in Powershell, the idea is not use the QMC)  so I created a script in order to do this steps 

cvalarcon_0-1647460419842.png

as you can see in the attach I create a .txt file to get the id task number .
But I don´k now how can I get this id task in a variable in order to add in the script to reload the task (3 step)

Thanks

 

 

Levi_Turner
Employee
Employee

You didn't display where that JSON blob came from, but I'm guessing it's from the cat command on line 19. Something like this should work:

$myTask = (Get-Content /my/file.txt | ConvertFrom-Json).id

(cat is just an alias for Get-Content)

cvalarcon
Contributor III
Contributor III
Author

Hi I like to import an qvf app in Powershell using  qlik-cli  : 

Import-QlikApp -file C:\Users\calarcon\Documents\PASAJES\FETR0013855\STG_TRANSACCIONES_N30_COMPLIANCE.qvf  

the result is :

Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At C:\Program Files (x86)\WindowsPowerShell\Modules\Qlik-Cli\functions\core.ps1:66 char:23
+ $result = Invoke-RestMethod @paramInvokeRestMethod @params
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Can you help me about this , how can I do this ? 

Thanks