Qlik-Cli-Windows icon indicating copy to clipboard operation
Qlik-Cli-Windows copied to clipboard

New-QlikCustomProperties cannot run with Powershell objects from Json with Invoke-RESTmethod error.

Open Kev-kutkin opened this issue 3 years ago • 4 comments

I am trying to migrate custom properties using Qlik-Cli.

Situation: I have successfully exported all the custom properties using Get-QlikCustomProperty to a Json file. Now, I would like to import the same json file to a QMC for another environment (in a new Qlik Sense server). In the Json file, it has many blocks of keys-values for each QlikUsers by having their respective IDs, names, objectTypes, etc.

Failure encountered: (1) I cannot use the New-QlikCustomProperty Cmdlets in a ForEach loop, executing in Powershell ISE with administrator rights, by encountering Invoke-Restmethod's error.

(2) I cannot use the Import-QlikContents Cmdlets to import the Powershell objects that I have performed ConvertFrom-Json despite Qlik Sense connection is successful.

Question: Can I know what should I do to use Qlik-Cli module to import the Custom-Properties' contents in a Json file to a connected QMC from Powershell ISE since the New-QlikCustomProperties does not work. I am currently using the Qlik Sense Enterprise (not Cloud)?

Kev-kutkin avatar Sep 15 '21 20:09 Kev-kutkin

When you call the Get-QlikCustomProperty ensure that you use the -raw parameter.

as an example the export script will look like this, you may need to adjust the file path and add any required filters on the get command

#Export to file
$QlikCustomProperties = Get-QlikCustomProperty -full -raw
$QlikCustomPropertiesJson = $QlikCustomProperties|ConvertTo-Json
$QlikCustomPropertiesJson|Out-File c:\temp\QlikCustomProperties.Json

transfer the out-file to the other environment and the following should work

#Import from file
$ImportedCPs = Get-Content c:\temp\QlikCustomProperties.Json|ConvertFrom-Json
$ImportedCPs |Import-QlikObject

Nillth avatar Sep 16 '21 06:09 Nillth

Good day @Nillth ,

I have used the exact script that you have used above. However, I face the issue that I raised in this post. So, I provide you a picture to show you the error. I hope you could provide me with more insights.

error_qlik-clin

Thank you for your reply.

Kev-kutkin avatar Sep 16 '21 11:09 Kev-kutkin

Can you please confirm the Export process uses the -Raw command

Nillth avatar Sep 16 '21 14:09 Nillth

@Nillth , Sorry for the late response. I have verified that the -Raw has been used in my Export script. Also, I face the same issue when executing other actions that 'import' other objects to the Qlik Sense server. So, My /qmc is not reflecting the presence of the new objects.

Kev-kutkin avatar Oct 04 '21 01:10 Kev-kutkin