Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

.net SDK static header authentication help needed

I am new to the qlik sense server world and I’m currently stuck trying to figure out an issue with the ability to log in using the static header method.  I’m currently using the .net SDK to do my work with the qlik engine to attempt to meet the requirements that have been asked of me on this project and I’m able to connect just fine using the AsNtlmUserViaProxy function.  My problem comes in when I attempt to connect using the AsStaticHeaderUserViaProxy method, I get this error "Connection failed after 4 attempts. Unable to keep connection open: Failed to ensure open connection: One or more errors occurred."  To the best of my knowledge this method only needs the userId and HeaderAuthenticationName.

I’m not sure what I’m doing wrong but I’ll include what code I have written that works just fine with the NTLM but not the header as well as screen shots of how the virtual proxy is setup in hopes that someone is able to help me figure this out.

This is just a proof of concept application to show that what is being asked can be done, which I know it can, I just need to figure out how to use this alternate connection method because not everyone connecting to this will be in our active directory.

Code I’ve written to obtain object data:

public JsonResult Index()
{
String appId = "Testing_app_1";
IApp app;
string data = "";

try
{

                ILocation location = Qlik.Engine.Location.FromUri(new Uri("http://<server IP address>/"));

                location.VirtualProxyPath = "QUP";

                location.AsStaticHeaderUserViaProxy("qlikusr1", "hdr-usr");

              //If i comment out the previous two lines and uncomment the following one I connect just fine

              //and obtain the data that I'm expecting to be able to obtain because of Active Directory

                //location.AsNtlmUserViaProxy(proxyUsesSsl: false);

                var appIdentifier = location.AppWithNameOrDefault(appId);

                if (appIdentifier == null)

                {

                    data = "The app (" + appId + ") does not exist.";

                    return Json(data, JsonRequestBehavior.AllowGet);

                }

                ISession session = Qlik.Engine.Session.WithApp(appIdentifier, SessionType.Default);

                app = location.App(appIdentifier, session, noData: false);

            }

            catch (MethodInvocationException invocationException)

            {

                data = "Error for details see invocationException.InvocationError.Code.";

                return Json(data, JsonRequestBehavior.AllowGet);

            }

            catch (Exception exception)

            {

                data = exception.Message;

                return Json(data, JsonRequestBehavior.AllowGet);

            }

          NxAppLayout appLayout = app.GetAppLayout();

            if (appLayout.IsOpenedWithoutData)

            {

                data = appId + " - Opened without data";

            }

            else

            {

                IGenericObject appObject;

                appObject = app.GetObject<GenericObject>("NdmtmPL");

                List<string> result = new List<string>();

                List<NxPage> list = new List<NxPage>();

                NxPage page = new NxPage();

                page.Height = 5000;

                page.Left = 0;

                page.Top = 0;

                page.Width = 2;

                list.Add(page);

                IEnumerable<NxPage> dataPages = list;

                IEnumerable<NxDataPage> NxDataPage = appObject.GetHyperCubeData("/qHyperCubeDef", dataPages);

                IEnumerable<NxCellRows> info = NxDataPage.First().Matrix;

                return Json(info, JsonRequestBehavior.AllowGet);

            }

            return Json(data, JsonRequestBehavior.AllowGet);

        }

Capture1.PNG

Capture.PNG

1 Solution

Accepted Solutions
Not applicable
Author

And figured out my own problem, it turns out all the code is correct but the user I was told to use didn't have access allocated to it.  Once that was done I got the data I was expecting to get.

View solution in original post

1 Reply
Not applicable
Author

And figured out my own problem, it turns out all the code is correct but the user I was told to use didn't have access allocated to it.  Once that was done I got the data I was expecting to get.