Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
mjperreault
Creator
Creator

QRS API Make Copy Powershell

Hi All,

 

I have the below powershell script which is successfully duplicating an app in my Qlik Sense site.

 

 

$qlikserver = 'myqlikserver'
$appid = 'fee68b53-e3e3-4ddf-18bb-0fce33920072'

$xrfkey = "iX83QmNlvu87yyAB"

$url = "https://$($qlikserver)/header/qrs/app/$($appid)/copy?xrfkey=$($xrfkey)"
$headers = @{}
$headers.Add("X-Qlik-xrfkey","$xrfkey")
$headers.Add("X-Qlik-User","UserDirectory=INTERNAL;UserId=sa_repository")
$headers.Add("Header","myuser")
$body = ''

Invoke-RestMethod -Uri $url -Method Post -Body $body -ContentType 'application/json' -Headers $headers

 



However once I try and add the name parameter to the path I get a 403 error.

 

 

$qlikserver = 'myqlikserver'

$xrfkey = "iX83QmNlvu87yyAB"
$appid = 'fee68b53-e3e3-4ddf-18bb-0fce33920072'
$appname = 'mycopy'

$url = "https://$($qlikserver)/header/qrs/app/$($appid)/copy?name=$($appname)?xrfkey=$($xrfkey)"
$headers = @{}
$headers.Add("X-Qlik-xrfkey","$xrfkey")
$headers.Add("X-Qlik-User","UserDirectory=INTERNAL;UserId=sa_repository")
$headers.Add("Header","myuser")
$body = ''

Invoke-RestMethod -Uri $url -Method Post -Body $body -ContentType 'application/json' -Headers $headers

 

 




Does anyone have any thoughts?

Thanks,
Mark

Labels (2)
1 Solution

Accepted Solutions
Damien_V
Support
Support

Hello @mjperreault 

There is a syntax mistake on this line:

$url = "https://$($qlikserver)/header/qrs/app/$($appid)/copy?name=$($appname)?xrfkey=$($xrfkey)"

It should be  ..&xrfkey=..

When you have several URL parameters, the other parameters should be preceded by &

You are getting 403 because the xrfkey key doesn't get passed.

If the issue is solved please mark the answer with Accept as Solution.

View solution in original post

2 Replies
Damien_V
Support
Support

Hello @mjperreault 

There is a syntax mistake on this line:

$url = "https://$($qlikserver)/header/qrs/app/$($appid)/copy?name=$($appname)?xrfkey=$($xrfkey)"

It should be  ..&xrfkey=..

When you have several URL parameters, the other parameters should be preceded by &

You are getting 403 because the xrfkey key doesn't get passed.

If the issue is solved please mark the answer with Accept as Solution.
mjperreault
Creator
Creator
Author

Thank you @Damien_V !