jparis / qrs-interact

Inactive - QRS Interact is a simple javascript library that allows users to send queries to the Qlik Sense Repository Service.
GNU General Public License v3.0
10 stars 7 forks source link

Export App #58

Closed krishnakumar89 closed 5 years ago

krishnakumar89 commented 5 years ago

How to export APP, export APP call 1 is working fine, How to call the download path parameter of first response.

jparis commented 5 years ago

Pretty sure that is just a standard GET request to a URL that returns a file. You can google how to download a file using the language/framework of your choice and follow the instructions there, there is nothing qrs or Qlik specific at that point.

krishnakumar89 commented 5 years ago

Hi I am trying the options available in help.qlik.com, It says exporting an app using QRS is two steps. STEP 1. qrs/app/export STEP 2. use the download path parameter to get the file.

I was able to complete STEP1 and got the download path, not sure how to proceed on the STEP 2. You are saying step 2 mentioned in help.qlik,com is out of QRS and we can't do via QRS Interact ?

jparis commented 5 years ago

Realize it only supports JSON responses, would need to add some logic to support responses that aren't JSON (aka app export).

My bad, mis-understood, but what you are asking for is currently not supported. Feel free to make the change and create a pull request though.

krishnakumar89 commented 5 years ago

Thanks for confirming, I can try a different approach on exporting. Thought I missed some syntax or steps for download.

jparis commented 5 years ago

Just realized it should work, I checked the code:

if (bufferResponse.length != 0) {
    try {
        jsonResponse = JSON.parse(bufferResponse);
    } catch (e) {
        resolve({
            "statusCode": statusCode,
            "body": bufferResponse
        });
    }
}

It tries to parse as JSON, and if it fails, it should just return the buffer. So store the buffer into a file, and it should all work. If that fails, then there's a bug in either the library or your code.

krishnakumar89 commented 5 years ago

I guess I found the issue, but not sure how to rectify it here. https://help.qlik.com/en-US/sense-developer/June2019/Subsystems/RepositoryServiceAPI/Content/Sense_RepositoryServiceAPI/RepositoryServiceAPI-App-Export-App-Two-Calls.htm

By default, qrs is prefixed to all the api calls, Whereas in step 2 of export, there is no prefix of qrs in the api endpoint, which is throwing me error 404 No matching api end point found.

jparis commented 5 years ago

Yes, so I wrote a quick test here to see, and it's indeed a bug on my end. I will try to fix it tomorrow.

Roughly what my code looked like:

instance.Post(
    '/app/bd333f5b-752c-4e73-94c1-50d9782a279c/export/bd332f6b-752c-4e73-94c1-50d9782a279c', {},
    'json'
).then(function(result) {
    console.log(result.body);
    downloadPath = result.body["downloadPath"];
}).then(function() {
    instance.Get(downloadPath)
        .then(function(result) {
            console.log(result.statusCode);
            console.log(result.body);
        })
        .catch(function(error) {
            console.log(error);
        });
});

You are correct in that the qrs prefix should not exist on tempcontent calls.

jparis commented 5 years ago

Fixed in v4.0.0