I am getting this error at "request.GetResponse()" trying to resolve this error but no luck.

My code is below:

string siteId = "37c9137b-bdd1-4d4c-90d4-2377097bcff8";
string uploadSessionID= "973:A1F6D5DC95BF49A483401169D52AEC21-0:0"
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://192.168.1.169:8000/api/2.0/sites/" + siteId + "/fileUploads/" + uploadSessionID);

string Contents = File.ReadAllText(filePath);

request.Method = "PUT";
request.Headers["X-Tableau-Auth"] = HttpContext.Current.Session["authToken"].ToString();
                request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
                request.Headers.Add("Accept-Language", "en-US,en;q=0.5");
                request.KeepAlive = true;
                request.ContentType = "multipart/mixed";
                request.Headers.Add("boundary", "--xxxxxxxPOSTxxBOUNDARY");

using (var sw = new StreamWriter(request.GetRequestStream()))
                {
                    sw.Write(Contents);
                    sw.Flush();
                }

                Stream responseStream = null;

                using (var httpResponse = (HttpWebResponse)request.GetResponse())
                {
                    try
                    {
                        responseStream = httpResponse.GetResponseStream();

                        using (var streamRdr = new StreamReader(responseStream))
                        {
                            var response2 = streamRdr.ReadToEnd();
                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.LoadXml(response2);

                            //Display all the book titles.
                            XmlNodeList elemList = xmlDoc.GetElementsByTagName("fileSize");
                            for (int i = 0; i < elemList.Count; i++)
                            {
                                fileSize = elemList[i].Attributes[0].Value;
                            }
                            HttpContext.Current.Session["fileSize"] = fileSize;
                            httpResponse.Close();
                        }
                    }
                    finally
                    {
                        if (responseStream != null)
                        {
                            responseStream.Dispose();
                        }
                    }
                }

I am using Tableau Server to connect remotely on another PC. A lot of questions are raised with the same issue but none of them resolves my error.

Related posts

Recent Viewed