无法从Tableau Server获取令牌

时间:2019-05-21 11:51:44

标签: tableau tableau-server

我在下面的链接中集成Web应用程序(asp .net mvc)的Tableau报告,

https://onlinehelp.tableau.com/current/server/en-us/trusted_auth.htm https://onlinehelp.tableau.com/current/server/en-us/trusted_auth_webrequ.htm

代码:

            var uri = "http://<server ip>:8000/trusted";
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("username ", "<user>");
            parameters.Add("target_site", "<site>");
            var bodyParameters = new ArrayList();
            foreach (var parameter in parameters)
            {
                bodyParameters.Add(string.Format("{0}={1}", HttpUtility.UrlEncode(parameter.Key), HttpUtility.UrlEncode(Convert.ToString(parameter.Value))));
            }
            string requestBody = String.Join("&", bodyParameters.ToArray());
            var request = WebRequest.CreateHttp(uri);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            try
            {
                using (var writer = new StreamWriter(request.GetRequestStream()))
                {
                    writer.Write(requestBody);
                }
                var response = (HttpWebResponse)request.GetResponse();
                using (var reader = new StreamReader(response.GetResponseStream()))
                {
                    String body = reader.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                string str = ex.Message.ToString();
            }

我的机器已注册为Tableau Server上的受信任主机,但是当我请求令牌时,我仍然得到-1。

0 个答案:

没有答案