Skip to main content

Integration, Extension & APIs

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

Announcements
CUSTOMERS ONLY: Now accepting customer applications for the 2023 Luminary Program: SUBMIT NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
kassyernar
Partner - Contributor
Partner - Contributor

QRS POST Node js

I'm trying to call this post / app / content / table method in nodejs, but I get the error: Missing parameter value (s). What am I doing wrong?

 

var https = require('https');
var fs = require('fs');
var options = {
"rejectUnauthorized": false,
hostname: 'test.test.com',
path: '/qrs/app/content/table?xrfkey=0123456789abcdef&name=FindLongLatImported',
method: 'POST',
port:4242,
headers: {
'x-qlik-xrfkey' : '0123456789abcdef',
'X-Qlik-User' : 'UserDirectory= Internal; UserId= sa_repository',
'Content-Type': 'application/json'
},
key: fs.readFileSync("C:\\Users\\myuser\\nodeJS\\certificates\\client_key.pem"),
cert: fs.readFileSync("C:\\Users\\myuser\\nodeJS\\certificates\\client.pem"),
ca: fs.readFileSync("C:\\Users\\myuser\\nodeJS\\certificates\\root.pem")
};
var req = https.request(options, function (res) {
var responseString = "";
res.on("data", function (data) {
responseString += data;
});
res.on("end", function () {
console.log(responseString);
});
});
req.write('"41439c69-2091-4d5c-9dcc-a39431caa9d4"');
req.end();

 

Error: Missing parameter value(s)

 

Labels (4)
4 Replies
Levi_Turner
Employee
Employee

Here's an example that I have doing a POST:

 

var fs = require('fs');
var request = require('request');

fs.readFile('C:\\Scripts\\NodeJS\\foo.xml', function (err, data) {
    if (err) return console.error(err);
  
    options = {
        url: 'https://usral-ltu2.qliktech.com:4242/qrs/contentlibrary/Default/uploadfile?externalpath=foo.xml&over...',
        method: 'POST',
        headers: {
           'x-qlik-xrfkey' : 'abcdefghijklmnop',
           'X-Qlik-User' : 'UserDirectory= Internal; UserId= sa_repository ',
           'Content-Type' : 'application/json'
        },
        key: fs.readFileSync('C:\\ProgramData\\Qlik\\Sense\\Repository\\Exported Certificates\\.Local Certificates\\client_key.pem'),
        cert: fs.readFileSync("C:\\ProgramData\\Qlik\\Sense\\Repository\\Exported Certificates\\.Local Certificates\\client.pem"),
        ca: fs.readFileSync("C:\\ProgramData\\Qlik\\Sense\\Repository\\Exported Certificates\\.Local Certificates\\root.pem"),
        body: data
        
    };
    // Needed for NodeJS 10.x:
    process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
  
    request.post(options, function (err, message, data) {
      if (err) return console.error(err);
  
      console.log(data)
    });
  });

 

Obviously that has many hard-coded values which need adjusting, but feel free to use it as a base.

Since the options > url value is being truncated. Here it is: https://usral-ltu2.qliktech.com:4242/qrs/contentlibrary/Default/uploadfile?externalpath=foo.xml&over...

kassyernar
Partner - Contributor
Partner - Contributor
Author

 

var https = require('https');
var fs = require('fs');
const data = JSON.stringify({
    id: "a6261e01-302f-4e3f-8fb9-cb6a447c591a",
    createdDate: "2019-01-14T11:57:21.331Z",
    modifiedDate: "2019-01-14T11:57:21.331Z",
    modifiedByUserName: "INTERNAL\\sa_repository",
    schemaPath: "DataConnection",
    privileges: null,
    customProperties: "",
    owner: {"id":"a909e838-c99f-4f40-8976-382fd77f8f65","userId":"sa_repository","userDirectory":"INTERNAL","name":"sa_repository","privileges":null},
    name: "QLogs",
    connectionstring: "CUSTOM CONNECT TO \"provider=QvOdbcConnectorPackage.exe;driver=postgres;host=test-server;port=4432;db=QLogs;FetchTSWTZasTimestamp=1;MaxVarcharSize=262144;\"",
    type: "QvOdbcConnectorPackage.exe",
    engineObjectId: "a6261e01-302f-4e3f-8fb9-cb6a447c591a",
    username : "qlogs_reader",
    password : "Ql1k-ReaDeR+{20!%}",
    logOn : 0,
    architecture : 0,
    tags : ""
})
var options = {
    "rejectUnauthorized": false,
   hostname: 'test.test.kz',
   path: '/qrs/dataconnection?xrfkey=0123456789abcdef',
   method: 'POST',
   port:4242,
    headers: {
      'x-qlik-xrfkey' : '0123456789abcdef',
      'X-Qlik-User' : 'UserDirectory= Internal; UserId= sa_repository',
      'Content-Type': 'application/json'
   },
   key: fs.readFileSync("C:\\Users\\MyUser\\nodeJS\\certificates\\client_key.pem"),
   cert: fs.readFileSync("C:\\Users\\MyUser\\nodeJS\\certificates\\client.pem"),
};
var req = https.request(options, function (res) {
    var responseString = "";
    res.on("data", function (data) {
        responseString += data;
    });
    res.on("end", function () {
        console.log(responseString);
    });
});
req.write(data);
req.end();

 

 

I almost managed to call the POST-api, but he does not accept my parameters ... I get the error: Object reference does not indicate an object instance.
You can get foo.xml to run your code

Levi_Turner
Employee
Employee

This is running for me:

var https = require('https');
var fs = require('fs');
const data = JSON.stringify({
    schemaPath: "DataConnection",
    privileges: null,
    // Adjusted from "" to []
    customProperties: [],
    // Changed ID for my sa_repository account
    owner: {"id":"5334b296-493b-46ee-b621-79ba238ceb2c","userId":"sa_repository","userDirectory":"INTERNAL","name":"sa_repository","privileges":null},
    // Adjusted name to a unique name
    name: "QLogs1",
    connectionstring: "CUSTOM CONNECT TO \"provider=QvOdbcConnectorPackage.exe;driver=postgres;host=test-server;port=4432;db=QLogs;FetchTSWTZasTimestamp=1;MaxVarcharSize=262144;\"",
    type: "QvOdbcConnectorPackage.exe",
    engineObjectId: "a6261e01-302f-4e3f-8fb9-cb6a447c591a",
    username : "qlogs_reader",
    password : "Ql1k-ReaDeR+{20!%}",
    logOn : 0,
    architecture : 0,
    // Adjusted from "" to []
    tags : []
})
var options = {
    "rejectUnauthorized": false,
    // Adjusted host
    hostname: 'usral-ltu2.qliktech.com',
    path: '/qrs/dataconnection?xrfkey=0123456789abcdef',
    method: 'POST',
    port:4242,
    headers: {
      'x-qlik-xrfkey' : '0123456789abcdef',
      'X-Qlik-User' : 'UserDirectory= Internal; UserId= sa_repository',
      'Content-Type': 'application/json'
   },
   // Adjusted path to cert
   key: fs.readFileSync("C:\\ProgramData\\Qlik\\Sense\\Repository\\Exported Certificates\\.Local Certificates\\client_key.pem"),
   cert: fs.readFileSync("C:\\ProgramData\\Qlik\\Sense\\Repository\\Exported Certificates\\.Local Certificates\\client.pem"),
};
var req = https.request(options, function (res) {
    var responseString = "";
    res.on("data", function (data) {
        responseString += data;
    });
    res.on("end", function () {
        console.log(responseString);
    });
});
req.write(data);
req.end();
kassyernar
Partner - Contributor
Partner - Contributor
Author

Try calling this method:

/qrs/app/content/table?xrfkey=0123456789abcdef