<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Exporting apps with Node JS in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Exporting-apps-with-Node-JS/m-p/1623759#M11302</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been wrestling with the qrs api for the past few days to create a process for moving apps from one environment to another. Currently my only goal is to download an app &amp;amp; upload it back onto the hub with a different name - I seem to have trouble with the app format as it is not recognized. Any help? Below is my request (excuse the poor text formatting).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var https = require('https');&lt;BR /&gt;var fs = require('fs');&lt;/P&gt;&lt;P&gt;var targetApp = 'Sandbox'&lt;BR /&gt;var options = {&lt;BR /&gt;hostname: &amp;lt;server.name&amp;gt;,&lt;BR /&gt;port: 4242,&lt;BR /&gt;path: '/qrs/app?xrfkey=abcdefghijklmnop',&lt;BR /&gt;method: 'GET',&lt;BR /&gt;headers: {&lt;BR /&gt;'x-qlik-xrfkey' : 'abcdefghijklmnop',&lt;BR /&gt;'X-Qlik-User' : 'UserDirectory= INTERNAL; UserId= sa_repository'&lt;BR /&gt;},&lt;BR /&gt;key: fs.readFileSync("client_key.pem"),&lt;BR /&gt;cert: fs.readFileSync("client.pem"),&lt;BR /&gt;ca: fs.readFileSync("root.pem")&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//get app list&lt;/P&gt;&lt;P&gt;https.get(options, function(res) {&lt;BR /&gt;console.log("Got response: " + res.statusCode);&lt;BR /&gt;var body = '';&lt;BR /&gt;res.on("data", function(chunk) {&lt;BR /&gt;body += chunk;&lt;BR /&gt;});&lt;BR /&gt;res.on("end", function() {&lt;BR /&gt;var appList = JSON.parse(body);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//find target app id&lt;BR /&gt;var targetAppId = '';&lt;BR /&gt;for(var i = 0;i &amp;lt; appList.length;i++){&lt;BR /&gt;if(targetApp == appList[i].name){&lt;BR /&gt;var targetAppId = appList[i].id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//1st export step of target app&lt;BR /&gt;options.path = '/qrs/app/' + targetAppId + '/export/' + targetAppId + '?skipData=false&amp;amp;xrfkey=abcdefghijklmnop';&lt;BR /&gt;options.method = 'POST';&lt;BR /&gt;https.get(options, function(resp) {&lt;BR /&gt;console.log("Got response (Export1): " + resp.statusCode);&lt;BR /&gt;var exportjson = '';&lt;BR /&gt;resp.on("data", function(chunk) {&lt;BR /&gt;exportjson += chunk;&lt;BR /&gt;});&lt;BR /&gt;resp.on('end',function(){&lt;BR /&gt;var exportobj = JSON.parse(exportjson);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//2nd export step on target app&lt;BR /&gt;options.path = exportobj.downloadPath + '&amp;amp;xrfkey=abcdefghijklmnop';&lt;BR /&gt;options.method = 'GET';&lt;BR /&gt;https.get(options, function(re) {&lt;BR /&gt;console.log('Got response (Export2): ' + re.statusCode);&lt;BR /&gt;var rawApp = '';&lt;BR /&gt;re.on('data',function(chunk){&lt;BR /&gt;rawApp += chunk;&lt;BR /&gt;});&lt;BR /&gt;re.on('end',function(){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//upload app with new name Test. This is where it fails with a 500 error due to invalid format&lt;BR /&gt;options.headers['Content-Type'] = 'application/vnd.qlik.sense.app';&lt;BR /&gt;options.path = '/qrs/app/upload?name=Test&amp;amp;xrfkey=abcdefghijklmnop';&lt;BR /&gt;options.method = 'POST';&lt;BR /&gt;&lt;BR /&gt;var uploadApp = https.request(options,function(response){&lt;BR /&gt;console.log('Got response (upload): ' + response.statusCode);&lt;BR /&gt;response.on('data',function(chunk){console.log('body: ' + chunk);});&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;uploadApp.write(rawApp );&lt;BR /&gt;uploadApp.end();&lt;BR /&gt;//fs.writeFile(targetApp + '.qvf',rawApp,function (err){&lt;BR /&gt;// console.log(err);&lt;BR /&gt;//});&lt;BR /&gt;});&lt;BR /&gt;}).on('error', function(e) {&lt;BR /&gt;console.log("Got error: " + e.message);&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;});&lt;BR /&gt;}).on('error', function(e) {&lt;BR /&gt;console.log("Got error: " + e.message);&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;}).on('error', function(e) {&lt;BR /&gt;console.log("Got error: " + e.message);&lt;BR /&gt;&lt;BR /&gt;});&lt;/P&gt;</description>
    <pubDate>Fri, 13 Sep 2019 14:46:31 GMT</pubDate>
    <dc:creator>Pirolli</dc:creator>
    <dc:date>2019-09-13T14:46:31Z</dc:date>
    <item>
      <title>Exporting apps with Node JS</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Exporting-apps-with-Node-JS/m-p/1623759#M11302</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been wrestling with the qrs api for the past few days to create a process for moving apps from one environment to another. Currently my only goal is to download an app &amp;amp; upload it back onto the hub with a different name - I seem to have trouble with the app format as it is not recognized. Any help? Below is my request (excuse the poor text formatting).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var https = require('https');&lt;BR /&gt;var fs = require('fs');&lt;/P&gt;&lt;P&gt;var targetApp = 'Sandbox'&lt;BR /&gt;var options = {&lt;BR /&gt;hostname: &amp;lt;server.name&amp;gt;,&lt;BR /&gt;port: 4242,&lt;BR /&gt;path: '/qrs/app?xrfkey=abcdefghijklmnop',&lt;BR /&gt;method: 'GET',&lt;BR /&gt;headers: {&lt;BR /&gt;'x-qlik-xrfkey' : 'abcdefghijklmnop',&lt;BR /&gt;'X-Qlik-User' : 'UserDirectory= INTERNAL; UserId= sa_repository'&lt;BR /&gt;},&lt;BR /&gt;key: fs.readFileSync("client_key.pem"),&lt;BR /&gt;cert: fs.readFileSync("client.pem"),&lt;BR /&gt;ca: fs.readFileSync("root.pem")&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//get app list&lt;/P&gt;&lt;P&gt;https.get(options, function(res) {&lt;BR /&gt;console.log("Got response: " + res.statusCode);&lt;BR /&gt;var body = '';&lt;BR /&gt;res.on("data", function(chunk) {&lt;BR /&gt;body += chunk;&lt;BR /&gt;});&lt;BR /&gt;res.on("end", function() {&lt;BR /&gt;var appList = JSON.parse(body);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//find target app id&lt;BR /&gt;var targetAppId = '';&lt;BR /&gt;for(var i = 0;i &amp;lt; appList.length;i++){&lt;BR /&gt;if(targetApp == appList[i].name){&lt;BR /&gt;var targetAppId = appList[i].id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//1st export step of target app&lt;BR /&gt;options.path = '/qrs/app/' + targetAppId + '/export/' + targetAppId + '?skipData=false&amp;amp;xrfkey=abcdefghijklmnop';&lt;BR /&gt;options.method = 'POST';&lt;BR /&gt;https.get(options, function(resp) {&lt;BR /&gt;console.log("Got response (Export1): " + resp.statusCode);&lt;BR /&gt;var exportjson = '';&lt;BR /&gt;resp.on("data", function(chunk) {&lt;BR /&gt;exportjson += chunk;&lt;BR /&gt;});&lt;BR /&gt;resp.on('end',function(){&lt;BR /&gt;var exportobj = JSON.parse(exportjson);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//2nd export step on target app&lt;BR /&gt;options.path = exportobj.downloadPath + '&amp;amp;xrfkey=abcdefghijklmnop';&lt;BR /&gt;options.method = 'GET';&lt;BR /&gt;https.get(options, function(re) {&lt;BR /&gt;console.log('Got response (Export2): ' + re.statusCode);&lt;BR /&gt;var rawApp = '';&lt;BR /&gt;re.on('data',function(chunk){&lt;BR /&gt;rawApp += chunk;&lt;BR /&gt;});&lt;BR /&gt;re.on('end',function(){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//upload app with new name Test. This is where it fails with a 500 error due to invalid format&lt;BR /&gt;options.headers['Content-Type'] = 'application/vnd.qlik.sense.app';&lt;BR /&gt;options.path = '/qrs/app/upload?name=Test&amp;amp;xrfkey=abcdefghijklmnop';&lt;BR /&gt;options.method = 'POST';&lt;BR /&gt;&lt;BR /&gt;var uploadApp = https.request(options,function(response){&lt;BR /&gt;console.log('Got response (upload): ' + response.statusCode);&lt;BR /&gt;response.on('data',function(chunk){console.log('body: ' + chunk);});&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;uploadApp.write(rawApp );&lt;BR /&gt;uploadApp.end();&lt;BR /&gt;//fs.writeFile(targetApp + '.qvf',rawApp,function (err){&lt;BR /&gt;// console.log(err);&lt;BR /&gt;//});&lt;BR /&gt;});&lt;BR /&gt;}).on('error', function(e) {&lt;BR /&gt;console.log("Got error: " + e.message);&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;});&lt;BR /&gt;}).on('error', function(e) {&lt;BR /&gt;console.log("Got error: " + e.message);&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;}).on('error', function(e) {&lt;BR /&gt;console.log("Got error: " + e.message);&lt;BR /&gt;&lt;BR /&gt;});&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 14:46:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Exporting-apps-with-Node-JS/m-p/1623759#M11302</guid>
      <dc:creator>Pirolli</dc:creator>
      <dc:date>2019-09-13T14:46:31Z</dc:date>
    </item>
  </channel>
</rss>

