6 Replies Latest reply: Mar 22, 2017 9:39 AM by Damir Uzunic RSS

    Unable to get targetId from QPS ticket response

      Based on blog:



      I make the json request as:


        string body = "{ 'UserId':'" + user + "','UserDirectory':'" + userdirectory + "','Attributes': []," + " 'TargetId':'cd4805f4-e25f-436a-847e-8e82208fb1e0'}";


      cd4805f4-e25f-436a-847e-8e82208fb1e0 being the app i want redirect to.


      However the response is only:


      { "Userid: user", "UserDirectory: userdirectory" }


      Why the targetid is not showing like in the blog example??




      Also i would like to know where to get proxy urls ( ie. /hub) in the format like the appid in this example is.

        • Re: Unable to get targetId from QPS ticket response
          Alexander Karlsson

          First check out the documentation at https://help.qlik.com/sense/en-us/developer/ which has tons of great samples of the APIs.


          How are you authenticating your requests? Are the certificates in place? XRF key injected into the header?

          The QPS url would be https://<servername>:4243/qps/<virtual proxy if your are using one>/ticket?xrfkey=<XRF key which matches the header>


          Check out this snippet which should give you some clues, https://gist.github.com/mindspank/4f93cac0c484cda3c500

            • Re: Unable to get targetId from QPS ticket response

              I am authenticating with C# thus:


              1. // get certificate


              private X509Certificate2 certificate_ { get; set; }


              public string TicketExampleCertificate()


                          // First locate the Qlik Sense certificate

                          X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);


                          certificate_ = store.Certificates.Cast<X509Certificate2>().FirstOrDefault(c => c.FriendlyName == "QlikClient");


                          ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };




              2. // Get the Qlik ticket

              public string TicketRequest2(string method, string server, string user, string userdirectory, string redirecturl)



                          //Create URL to REST endpoint for tickets

                          string url = "https://" + server + ":4243/qps/ticket";


                          //Create the HTTP Request and add required headers and content in Xrfkey

                          string Xrfkey = "0123456789abcdef";

                          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + "?Xrfkey=" + Xrfkey);

                          // Add the method to authentication the user


                          request.Method = method;

                          request.Accept = "application/json";

                          request.Headers.Add("X-Qlik-Xrfkey", Xrfkey);


                          string body = "{ 'UserId':'" + user + "','UserDirectory':'" + userdirectory + "','Attributes': []," + " 'TargetId':' " + redirecturl + "'}";

                          byte[] bodyBytes = Encoding.UTF8.GetBytes(body);


                          if (!string.IsNullOrEmpty(body))


                              request.ContentType = "application/json";

                              request.ContentLength = bodyBytes.Length;


                              Stream requestStream = request.GetRequestStream();

                              requestStream.Write(bodyBytes, 0, bodyBytes.Length);




                          // make the web request and return the content



                              HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                              Stream stream = response.GetResponseStream();

                              return stream != null ? new StreamReader(stream).ReadToEnd() : string.Empty;


                          catch (WebException ex)


                              using (var stream = ex.Response.GetResponseStream())

                              using (var reader = new StreamReader(stream))






                              return "Error";





              3. Reply: