Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
muhammadraza
Partner - Creator
Partner - Creator

Replace app on managed space from qlik sense enterprise client-managed environment through cli

I went to various forums and did lot of R&D but could not found proper method or way to replace an existing application on managed space in saas with an app existing in my Qliksense enterprise client. 

The same app was initially uploaded through the cli.

##Set the context to the SaaS instance of Qlik Sense
qlik context use QSESaaS1

##specify an app name for the imported app
$filepath="C:\temp\"
$filename="Demo SaaS"

##Issue the command so it returns the GUID for the app in SaaS to a variable or stdOut for future use.
$SaasAppId=$(qlik app import --file "$filepath/$filename.qvf" --mode new --name $filename | jq -r '.attributes.id')


Now I have made few changes in the same app (which is on Qliksense enterprise), and want to publish and replace the same app on saas managed space.

I have tried the following

qlik app publish update $($SaasAppId) --attributes-name "MyFirstSaasApp" --targetId $($target) --checkOriginAppId=false -v

 But I see every time a new app is being uploaded on personal space instead of replace on managed.

Kindly guide the correct way to achieve it.

Labels (3)
1 Solution

Accepted Solutions
d4nilomiranda
Partner - Contributor II
Partner - Contributor II

Hello Friends! Perhaps this main doubt has already been resolved, but I will leave my collaboration to other people who arrive here like me! hehe..


Example code follows:

First, let's find the IDs for Shared and Managed spaces.
We will add the app to a Shared space and then update it to the managed space.


## Specify the spaces to import and publish the app to
$targetSharedSpace = "YOUR SHARED SPACE"
$targetManagedSpace = "YOUR MANAGED SPACE"
## Managed Space and Shared Space
$managedSpaceId = (qlik space ls --filter $('name co \"' + $targetManagedSpace + '"') | ConvertFrom-Json).id
$sharedSpaceId = (qlik space ls --filter $('name co \"' + $targetSharedSpace + '"') | ConvertFrom-Json).id

@muhammadraza 

# Select the context for client-managed
qlik context use YOUR_CONTEXT

# Select the context for Qlik Cloud
qlik context use $cliContextSaaS
# Import the app to Qlik Cloud to a shared space
$cloudApp = qlik app import -f "YOUR QVF EXPORTED" --spaceId $sharedSpaceId | ConvertFrom-Json
#Capture ID and NAME this app
$cloudAppId = $cloudApp.attributes.id
$cloudAppName = $cloudApp.attributes.name

##### FIRST EXECUTION - NOT HAVE APP IN SPACES - DISCOMMENT AND COMMENT SECOND BLOCK#####
# Move the original app to a managed space
##Execute case not exists App in ManagedSpace
### qlik app publish create $cloudAppId --moveApp --originAppId $appCopyId --spaceId $managedSpaceId
#################################

##### NEXT EXECUTIONS - EXIST APP IN MANAGEDSPACE #####
# Return Id using Name for search in Space apponted
$appPublished = (qlik app ls -q --spaceId $managedSpaceId --name $cloudAppName | Select-Object -First 1 | qlik app get | ConvertFrom-Json).attributes.id
# Update app published in Managed Space.
qlik app publish update $cloudAppId --attributes-name $cloudAppName --targetId $appPublished --checkOriginAppId=false -v

# Remove app in a Shared Space
# Capture ID App from Name and ID Space
$sharedSpaceAppId = (qlik app ls -q --spaceId $sharedSpaceId --name $cloudAppName | Select-Object -First 1 | qlik app get | ConvertFrom-Json).attributes.id
qlik app rm $sharedSpaceAppId

View solution in original post

5 Replies
Daniele_Purrone
Support
Support

Hi @muhammadraza , since the best practice is that a managed-space is associated to an unpublished app in a shared or personal space app, I would say that it's better that you split the replacement into two phases:

  1. upload the updated app to a personal or shared space
  2. publish the app from the personal/shared space to the managed one
Daniele - Principal Technical Support Engineer & SaaS Support Coordinator at Qlik
If a post helps to resolve your issue, please accept it as a Solution.
muhammadraza
Partner - Creator
Partner - Creator
Author

Hello Daniele, thanks for the clarification. Now I am trying to replace the same app (from personal space to manage space) but getting 403. I thought the key might be lacking the permissions, but I am able to perform the same thing through Qlik Data Transfer using the same API key.

qlik app publish update "984ae09d-de17-4876-9593-1d127b2a42d2" --data="source" --attributes-name="test alpha beta app 11Jan" --targetId="49bdc01b-ed0c-4169-8542-efbe20059a4a" --checkOriginAppId=true -v

Waiting for response...
                       
PAYLOAD:
{
  "attributes": {
    "name": "test alpha beta app 11Jan"
  },
  "checkOriginAppId": true,
  "data": "source",
  "targetId": "49bdc01b-ed0c-4169-8542-efbe20059a4a"
}
< Cache-Control: no-store
< Connection: keep-alive
< Content-Length: 0
< Date: Thu, 12 Jan 2023 13:11:35 GMT
< Pragma: no-cache
< Strict-Transport-Security: max-age=15724800; includeSubDomains
Response time: 1s
Status: 403 Forbidden
Error: 403 - Forbidden (empty response)

 

Albert_Candelario

Hello @muhammadraza ,

Did you manage to sort it out?

Cheers,

ALbert

Please, remember to mark the thread as solved once getting the correct answer
Bhaskarkumar
Partner - Contributor III
Partner - Contributor III

@muhammadraza  able to get this working?

d4nilomiranda
Partner - Contributor II
Partner - Contributor II

Hello Friends! Perhaps this main doubt has already been resolved, but I will leave my collaboration to other people who arrive here like me! hehe..


Example code follows:

First, let's find the IDs for Shared and Managed spaces.
We will add the app to a Shared space and then update it to the managed space.


## Specify the spaces to import and publish the app to
$targetSharedSpace = "YOUR SHARED SPACE"
$targetManagedSpace = "YOUR MANAGED SPACE"
## Managed Space and Shared Space
$managedSpaceId = (qlik space ls --filter $('name co \"' + $targetManagedSpace + '"') | ConvertFrom-Json).id
$sharedSpaceId = (qlik space ls --filter $('name co \"' + $targetSharedSpace + '"') | ConvertFrom-Json).id

@muhammadraza 

# Select the context for client-managed
qlik context use YOUR_CONTEXT

# Select the context for Qlik Cloud
qlik context use $cliContextSaaS
# Import the app to Qlik Cloud to a shared space
$cloudApp = qlik app import -f "YOUR QVF EXPORTED" --spaceId $sharedSpaceId | ConvertFrom-Json
#Capture ID and NAME this app
$cloudAppId = $cloudApp.attributes.id
$cloudAppName = $cloudApp.attributes.name

##### FIRST EXECUTION - NOT HAVE APP IN SPACES - DISCOMMENT AND COMMENT SECOND BLOCK#####
# Move the original app to a managed space
##Execute case not exists App in ManagedSpace
### qlik app publish create $cloudAppId --moveApp --originAppId $appCopyId --spaceId $managedSpaceId
#################################

##### NEXT EXECUTIONS - EXIST APP IN MANAGEDSPACE #####
# Return Id using Name for search in Space apponted
$appPublished = (qlik app ls -q --spaceId $managedSpaceId --name $cloudAppName | Select-Object -First 1 | qlik app get | ConvertFrom-Json).attributes.id
# Update app published in Managed Space.
qlik app publish update $cloudAppId --attributes-name $cloudAppName --targetId $appPublished --checkOriginAppId=false -v

# Remove app in a Shared Space
# Capture ID App from Name and ID Space
$sharedSpaceAppId = (qlik app ls -q --spaceId $sharedSpaceId --name $cloudAppName | Select-Object -First 1 | qlik app get | ConvertFrom-Json).attributes.id
qlik app rm $sharedSpaceAppId