Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
JustinDallas
Specialist III
Specialist III

QlikSense C# SDK: Get stream name from IAppIdentifier

Hello Folks,

Given that I've got an IAppIdentifier, how do I go about getting the stream name?  I'm seeing there is an NxMeta object as the Meta property.  Sometimes I see a stream name, other times I don't.  I know I can get it from an App object, but I'd rather avoid "Apping" all the IAppIdentifiers if I don't have to.

 

JustinDallas_0-1588832642266.png

 

Any help is greatly appreciated.

Labels (3)
4 Replies
Øystein_Kolsrud
Employee
Employee

Properties that are part of the json response from the engine, but that are not mapped directly to C# properties of the encapsulating classes in the SDK can be accessed using the generic AbstractStructure methods. In your case, the code would look something like this:

 

 

var streamDef = appIdentifier.Meta?.Get<AbstractStructure>("stream");
var streamId = streamDef?.Get<string>("id");
var streamName = streamDef?.Get<string>("name");

 

 

The reason why the stream object is not always there is simply because not all apps are published to a stream.

You can read more about the AbstractStructure concept here:

https://help.qlik.com/en-US/sense-developer/April2020/Subsystems/NetSDKAPI/Content/Sense_NetSDKAPI/H...

https://help.qlik.com/en-US/sense-developer/April2020/Subsystems/NetSDKAPI/Content/Sense_NetSDKAPI/C...

 

Øystein_Kolsrud
Employee
Employee

But if you are going to work with that type of app meta data, then you might want to have a look at the QRS API. It provides more flexibility including filtering and ordering that is not available through the engine API. I recently posted this reply on another thread describing how to use that API to get the owners of the apps in C#. Getting stream information is very similar.

https://community.qlik.com/t5/Qlik-Sense-Integration-Extensions-APIs/Qlik-c-SDK-Get-App-owner/m-p/16...

JustinDallas
Specialist III
Specialist III
Author

I'll probably end up using the Rest API.  It seemed like some things were only available through the C# API (QlikEngine).  And while I didn't want to mix the two implementations, I may have to for the sake of simplicity and being reasonable.

Øystein_Kolsrud
Employee
Employee

In general it is the case that app meta data, like owner and stream, is the responsibility of the Repository service while the app contents is the responsibility of the Engine. But as you have seen, there is a certain overlap. But leveraging two different APIs here is not necessarily a bad thing.

If you want to use the library I mentioned in the other thread I linked to, then the code would look something like this (using Newtonsoft for Json handling):

var client = new RestClient(url);
client.AsNtlmUserViaProxy();
var apps = JArray.Parse(client.Get("/qrs/app"));
var appsAndStreams = apps.Select(app => (app["id"], app["stream"]));