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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
master_t
Partner - Creator II
Partner - Creator II

Exporting data with the .NET SDK doesn't work in Qlik Sense SaaS

I have an application that uses the .NET SDK (latest version, 16.3.0) that extracts data from some Qlik Sense objects, using the following code:

var obj = app.GetObject<GenericObject>("my-object-id");
var result = obj.ExportData(format, "/qHyperCubeDef", "out.xlsx", NxExportState.EXPORT_POSSIBLE);

 

This works perfectly with Qlik Sense Enterprise on-premise, however it fails in Qlik Sense SaaS, throwing an exception that says:

Qlik.Engine.MethodInvocationException: Access denied [5]:Access denied(ExportData)
   at Qlik.Engine.Communication.QlikConnection.AwaitResponseTask[T](T task, String methodName, CancellationToken cancellationToken)
   at Qlik.Engine.Communication.QlikConnection.AwaitResponse[T](Task`1 task, String methodName, CancellationToken cancellationToken)
   at Qlik.Engine.GenericObject.ExportData(NxExportFileType fileType, String path, String fileName, NxExportState exportState, Boolean serveOnce)

 

Any idea why this isn't working? I tested exporting the same object manually from the browser (right click -> download)  while connected with the same user I'm using with the SDK and it works correctly, so it doesn't seem to be a permission problem like the error message seems to imply...

Labels (2)
1 Solution

Accepted Solutions
Øystein_Kolsrud
Employee
Employee

That method is not available in QCS. May not be obvious at first sight, but there's a actually a remark in the documentation that states so:

https://help.qlik.com/en-US/sense-developer/May2022/Subsystems/NetSDKAPIref/Content/Qlik.Engine.Gene...

It's somewhat more visible in the raw engine API documentation:

https://help.qlik.com/en-US/sense-developer/May2022/Subsystems/EngineJSONAPI/Content/service-generic...

The flow for exporting data is handled differently in QCS, and you need to go through REST APIs to do so. There's a small example illustrating how to utilize the reporting service available here:

https://github.com/kolsrud/qlik_rest_sdk/blob/master/Qlik.Sense.RestClient/Examples/QcsExportExcel/P...

View solution in original post

7 Replies
Øystein_Kolsrud
Employee
Employee

That method is not available in QCS. May not be obvious at first sight, but there's a actually a remark in the documentation that states so:

https://help.qlik.com/en-US/sense-developer/May2022/Subsystems/NetSDKAPIref/Content/Qlik.Engine.Gene...

It's somewhat more visible in the raw engine API documentation:

https://help.qlik.com/en-US/sense-developer/May2022/Subsystems/EngineJSONAPI/Content/service-generic...

The flow for exporting data is handled differently in QCS, and you need to go through REST APIs to do so. There's a small example illustrating how to utilize the reporting service available here:

https://github.com/kolsrud/qlik_rest_sdk/blob/master/Qlik.Sense.RestClient/Examples/QcsExportExcel/P...

master_t
Partner - Creator II
Partner - Creator II
Author

As always, thanks for your quick and precise answers 👍

I'll study the API and see if I can re-implement the same flow. From what I can see from the docs, compared to the Enterprise Edition:

  • This only supports exporting in XLSX format, not CSV (not a big problem I guess)
  • This is not synced with the SDK session, so creating a temporary bookmark is required to keep the current selections and variables

Will post my findings when I've tested it. Thanks again for your support 👍

master_t
Partner - Creator II
Partner - Creator II
Author

I've tried this solution and it works, thank you again.

One more question though: I noticed in the documentation that the "type" property in the OutputItem definition supports various values, including csv.

However, it doesn't seem to work, if I try to use "csv" instead of "xlsx" I get the following error:

{
    "code": 400,
    "errors": [
        {
            "code": "REP-400000",
            "detail": "unsupported output type csv for sense-data-1.0 template",
            "title": "bad or malformed http request"
        }
    ],
    "message": "bad or malformed http request"
}

 

Is CSV output just not supported at all? Or am I just not building the request correctly?

The documentation is quite strange, because it states:

csv doesn't have csv output

Maybe I'm dumb, but what is that sentence even supposed to mean?

Øystein_Kolsrud
Employee
Employee

Hmm... I do seem to remember that CSV  export wasn't supported, but I don't remember the status of it. And that documentation could use some love and attention I guess...

master_t
Partner - Creator II
Partner - Creator II
Author

Thanks for the confirmation, I suspected it wasn't supported but the "csv" type in the docs made me doubt.

AkshayBheda
Contributor II
Contributor II

I am getting when I followed https://github.com/kolsrud/qlik_rest_sdk/blob/master/Qlik.Sense.RestClient/Examples/QcsExportExcel/P...

One or more errors occurred. (400: Bad Request, {"code":400,"message":"Query string not allowed","errors":[{"code":"REP-400000","title":"Query string not allowed"}]} error when authenticate with Session.

Instead of client.AsApiKeyViaQcs(apiKey); I used client.AsExistingSessionViaQcs(qcsSessionInfo); since I have different section access for different users, i want to export only data related to those users. Also, is there any documentation of bookmarks?

 

Also if I use AsJsonWebTokenViaQCS

i am getting One or more errors occurred. (400: Bad Request, {"code":400,"message":"bad or malformed http request","errors":[{"code":"REP-400020","detail":"The issuer is not compatible with a non browser like request" .. Error.

 

We currently moved from Qlik On-prem to Qlik Cloud and that has resulted in Broken export functionality, We were using genericObject.ExportData(NxExportFileType.EXPORT_OOXML) but for that i am getting Access Denied Error.

DBIT
Contributor III
Contributor III

Just FYI your examples no longer appear to exist or the links are broken.