Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
catalin
Partner - Contributor III
Partner - Contributor III

Bug or Feature - QS .NET SDK - ExportDataAsync

Hello!

 

I updated the QlikSense.NETSDK package to v15.4.0 and I am getting an error while using the same method as in the older version to ExportData from a generic object.

 

 

ExportDataResult result = await gen_obj.Session.RetryOnAbort(() =>
                            gen_obj.ExportDataAsync(fileType: NxExportFileType.EXPORT_OOXML, path: "/qHyperCubeDef", exportState: NxExportState.EXPORT_POSSIBLE);

 

 

 

And I get the error:

 

 

"Invalid method parameter(s) [-32602]:Invalid method parameter(s)(Method parameter list error)"

 

 

 

Has something changed? I saw only a new parameter, named serveOnce, but it seems optional as it has a default false value. Should I downgrade to a previous version?

Any help would be appreciated.

Thanks a lot!

Catalin

Labels (1)
1 Solution

Accepted Solutions
Øystein_Kolsrud
Employee
Employee

@rwunderlichis spot on. The version 15.4.0 of the .NET SDK is built based on the engine API definition for the May release of Qlik Sense. That's the "SCHEMA" bullet in the release notes.

Now for optional parameters that are not specified (like that "serveOnce" parameter in this case), the RPC request will be constructed based on the default C# value of the type of the argument. For reference-type parameters, this would be null, and the SDK simply removes such null-values from the request all together before sending it to the engine. But for value-type parameters (Boolean in this case), there is no way to distinguish the default value of "false" from the explicit value of "false", so the SDK doesn't know that you haven't explicitly specified it and sends on that argument to the engine. That's why this doesn't work when you connect a new SDK to an old engine. If that argument had been for instance a string instead, then the default value would have been null, and it would not have been sent to the engine and all would be good. But new optional arguments added to the engine API that are of types like int or bool will result in this problem. The engine API is backwards compatible, and the SDK is backwards compatible, but the SDK is not 100% backwards compatible with older versions of the engine.

There is a workaround though. If you want to call that method from a new SDK to an old engine, then you can explicitly specify the Request object and eliminate the optional parameter there. Like this:

var o = app.GetGenericObject("<id>");
var argNames = new [] {"qFileType", "qPath", "qExportState" };
var argValues = new object[] {
                  NxExportFileType.EXPORT_OOXML,
                  "/qHyperCubeDef",
                  NxExportState.EXPORT_POSSIBLE
                };
var req = new Request(null, o.Handle, "ExportData", argumentNames: argNames, arguments: argValues);
var r = o.Session.SendAsync(req, r => r.Value<ExportDataResult>("result")).Result;
Console.WriteLine(r.Url);

This call will work for both the May release of Qlik Sense and older versions as it does not send that "servedOnce" paramter.

View solution in original post

4 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

This is an issue when SDK package is at a higher level than the Qlik Engine. New parameters introduced by the SDK are not tolerated by the downlevel engine.  If you keep your SDK and Engine in sync you can avoid the issue.

If you are targeting multiple engines you either have to stick with the downlevel SDK or write a facade for the affected methods. 

Bug or Feature? You decide. 😀

-Rob

catalin
Partner - Contributor III
Partner - Contributor III
Author

Thank you very much for the insights, @rwunderlich!

Seems pretty odd, as I was using 15.2.2 and worked on much older engine versions. Also, in the release notes of 15.4.0 there's no mention of that new parameter for the method ExportDataAsync: serveOnce.

Anyway, I downgraded to 15.2.2 and all OK now. 

Thanks again for input!

Catalin

Øystein_Kolsrud
Employee
Employee

@rwunderlichis spot on. The version 15.4.0 of the .NET SDK is built based on the engine API definition for the May release of Qlik Sense. That's the "SCHEMA" bullet in the release notes.

Now for optional parameters that are not specified (like that "serveOnce" parameter in this case), the RPC request will be constructed based on the default C# value of the type of the argument. For reference-type parameters, this would be null, and the SDK simply removes such null-values from the request all together before sending it to the engine. But for value-type parameters (Boolean in this case), there is no way to distinguish the default value of "false" from the explicit value of "false", so the SDK doesn't know that you haven't explicitly specified it and sends on that argument to the engine. That's why this doesn't work when you connect a new SDK to an old engine. If that argument had been for instance a string instead, then the default value would have been null, and it would not have been sent to the engine and all would be good. But new optional arguments added to the engine API that are of types like int or bool will result in this problem. The engine API is backwards compatible, and the SDK is backwards compatible, but the SDK is not 100% backwards compatible with older versions of the engine.

There is a workaround though. If you want to call that method from a new SDK to an old engine, then you can explicitly specify the Request object and eliminate the optional parameter there. Like this:

var o = app.GetGenericObject("<id>");
var argNames = new [] {"qFileType", "qPath", "qExportState" };
var argValues = new object[] {
                  NxExportFileType.EXPORT_OOXML,
                  "/qHyperCubeDef",
                  NxExportState.EXPORT_POSSIBLE
                };
var req = new Request(null, o.Handle, "ExportData", argumentNames: argNames, arguments: argValues);
var r = o.Session.SendAsync(req, r => r.Value<ExportDataResult>("result")).Result;
Console.WriteLine(r.Url);

This call will work for both the May release of Qlik Sense and older versions as it does not send that "servedOnce" paramter.

Øystein_Kolsrud
Employee
Employee

The latest version of the .NET SDK (version v15.6.0) contains an improvement to the handling of default values for optional value type arguments. This improvement has the effect that when you omit the use of such values, or assign the default value to them, then those values will not be sent to the engine. This is analogous to how the handling of null-values for non-value types behave. This means that type of cross-version incompatibility issue encountered in this thread should no longer be an issue. The release is available on NuGet:

https://www.nuget.org/packages/QlikSense.NetSDK/15.6.0

Further information about what's new can be found in the release notes:

https://help.qlik.com/en-US/sense-developer/November2021/Subsystems/NetSDKAPIref/Content/ReleaseNote...