ahaydon / Qlik-Cli-Windows

Qlik-Cli for Windows
https://adamhaydon.uk/Qlik-Cli-Windows/
GNU General Public License v2.0
110 stars 51 forks source link

Invoke Rest-Method error #207

Closed Th3Vish closed 9 months ago

Th3Vish commented 1 year ago

Hey @ahaydon ,

Recently my Qlik cli script stopped working and started throwing the following error: Error message :

Invoke-RestMethod : Content-Length or Chunked Encoding cannot be set for an operation that does not write data.
At C:\Program Files\WindowsPowerShell\Modules\Qlik-Cli\1.22.0\functions\core.ps1:66 char:23
+ ...            $result = Invoke-RestMethod @paramInvokeRestMethod @params
+                         
[core.txt](https://github.com/ahaydon/Qlik-Cli-Windows/files/11371364/core.txt)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-RestMethod], ProtocolViolationException
    + FullyQualifiedErrorId : System.Net.ProtocolViolationException,Microsoft.PowerShell.Commands.InvokeRestMethodCo 
   mmand

I tried to debug this but couldn't understand and did not find any solution online as well. This script was working just fine since past few weeks. 1 thing did in between was to create a new virtual proxy using jwt authentication to try Qlik Cli SaaS and connect to Qlik on Prem but the virtual proxy was deleted later after few testing. Default proxy was never touched.

PS: I see there was a recent change in core.txt file can that be the issue?

ahaydon commented 1 year ago

Could you please confirm what command you are running that produced this error.

Th3Vish commented 1 year ago

Invoke-QlikPut -path /qrs/app/$($new.id)/replace?app=$($old.id)

Part of my Script where this error comes

2.For each app to be published by replacing the existing published app

foreach ($app in $apps.BaseName)

{
$new = Get-QlikApp -filter "name eq '$app' and published eq False"
$old = Get-QlikApp -filter  "name eq '$app' and published eq True"
Invoke-QlikPut -path /qrs/app/$($new.id)/replace?app=$($old.id)
}
Th3Vish commented 1 year ago

Hi @ahaydon ,

I did a full reinstallation and repeated the whole process and now facing error 400 What am I missing here? image

ahaydon commented 1 year ago

The change you mention in your original post only applies when uploading or downloading files so it won't be called by the Invoke-QlikPut function, you could try running the script with v1.21 if you want to be sure though.

Are you sure your Get-QlikApp commands are only returning a single app? If more than one app is returned then you will have a list of IDs in the URL. Try printing the output of the $new and $old variables or add the -Verbose switch to the Invoke-QlikPut to see the URL being called.

You can also use the Switch-QlikApp command for this, it calls the same URL so you don't have to build it yourself.

SathvikBelllala commented 1 year ago

Hi Ahaydon,

I have been using Qlik-CLI in order to work for a automation of the process for exporting an app from Onprem and import and publish it to Cloud but while trying to export an app from onprem to my local I am getting this INVOKE REST-METHOD ERROR... The commands which I have been using are:

  1. Export-QlikApp -id -filename "" This syntax is not allowing me to get the result all other commands such as Import, update are working fine.
  2. Tried importing everything into variables and automate the script but still getting that invoke error while exporting the app

Attaching the SS of the error as well please go through it and provide a solution for this. In SS there are 2 different approaches please do see them and both the approaches are throwing the same error.

CLI

Thanks in Advance, Sathvik Bellala