3 Replies Latest reply on Feb 13, 2014 12:50 AM by cevdet.bulut

    get ticket from ajax

    cevdet.bulut

      this is my sample code below:

      $.ajax({

         url: 'http://myserver:8080',

         type: 'post',

         data: 'username=myservername\myusername',

         success: function(data){

            console.log(data);

         },

         error: function(context){

           console.log(context);

         }

      });

       

      then i'm getting....

       

      "Error : Access is denied"....

       

      Any clue here???

        • 2. Re: get ticket from ajax
          cevdet.bulut

          I modified my codes for client and server side:

           

          server side code:

                  [HttpPost]

                  public ActionResult GetTableauTicket(string url, string username="", string site="", string ip = "")

                  {

                      var user = username;

                      var targetsite = site!="" ? "&target_site=" + site : "";

                      var clientip = ip!="" ? "&client_ip=" + ip : "";

           

           

                      var request = (HttpWebRequest)WebRequest.Create(url);

           

           

                      var encoding = new UTF8Encoding();

                      var postData = string.Format("username={0}{1}{2}", user, targetsite, clientip);

                      byte[] data = encoding.GetBytes(postData);

           

           

                      request.Method = "POST";

                      request.ContentType = "application/x-www-form-urlencoded";

                      request.ContentLength = data.Length;

           

           

                      using (var stream = request.GetRequestStream())

                      {

                          stream.Write(data, 0, data.Length);

                      }

           

           

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

                      var result = new StreamReader(response.GetResponseStream()).ReadToEnd();

                      return Json(new { ticket = new StreamReader(response.GetResponseStream()).ReadToEnd() });

                     

                  }

           

           

           

          client side code:

             var xticket = null;

              $(function() {

                  $.ajax({

                      url: "tableauservice/GetTableauTicket",

                      type: "post",

                      data: "url=http://localhost:8000/trusted&username=TESTINGSERVER\user1&client_ip=192.168.100.99",

                      success: function (ticket) {

                          xticket = ticket;

                          console.log('do i have the ticket?');

                          console.log(ticket);

                          console.log(ticket.ticket);

                      },

                      error: function (xhr, status, error) {

                          console.log('i got error here');

                          var err = eval("(" + xhr.responseText + ")");

                          console.log(err.Message);

                          console.log(status);

                          console.log(error);

                      }

                  });

              })

           

          in my tabsvc.yml :

          worker0.gateway.port: 8000

          wgserver.extended_trusted_ip_checking: true

          install.component.samples: false

          solr.port: 8001

          service.init.state: start

          worker0.wgserver.port: 8002

          vizqlserver.initialsql.disabled: false

          config.version: 12

          repository.port: 8001

          tomcat.http.port: 8001

          wgserver.trusted_hosts: 192.168.100.99

           

           

           

          result is, I'm not getting error, but my ticket is BLANK or EMPTY;

           

          xticket.ticket is = ""

          • 3. Re: get ticket from ajax
            cevdet.bulut

            Anyone knows why it's getting empty in ticket?