Qlik Community

Ask a Question

Integration, Extension & APIs

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

Announcements
LINKEDIN LIVE: Democratizing data to enhance customer-centricity. JULY 29TH REGISTER TODAY
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 (4)
1 Solution

Accepted Solutions
Damien_Villaret
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.

View solution in original post

2 Replies
Damien_Villaret
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.

View solution in original post

mjperreault
Creator
Creator
Author

Thank you @Damien_Villaret !