title: Call Slack API in vb.NET with a proxy
body: <p>Trying to call a Slack API through an app in vb.NET behind a proxy. However, I don't have an expertise in .NET, so it's somehow out of my league.</p>
  
  <p>This is the part of the code:</p>
  
  <pre><code>Private Function GetResponseFromPostRequest(ByVal url As String, ByVal variables As String) As String
      Dim content As String
  
      Dim postData() As Byte = Encoding.GetEncoding("utf-8").GetBytes(variables)
      Dim req As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
      Dim proxyObject As New WebProxy("http://thisismyproxy:thisismyport")
  
      req.Proxy = proxyObject
      req.Method = "POST"
  
      req.ContentType = "application/json"
      req.ContentLength = postData.Length
  
      Dim postStream As Stream = req.GetRequestStream()
      postStream.Write(postData, 0, postData.Length)
      postStream.Close()
  
      Using res As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)
          Using receiveStream As Stream = res.GetResponseStream()
              Dim readStream As New StreamReader(receiveStream, Encoding.GetEncoding("utf-8"))
              content = readStream.ReadToEnd()
          End Using
      End Using
  
      Return content
  
  End Function
  </code></pre>
  
  <p>Then call it like that:</p>
  
  <pre><code>GetResponseFromPostRequest("https://hooks.slack.com/services/....",  "{'text':'" &amp; slackTitle &amp; "'}")
  </code></pre>
  
  <p>Without the proxy, it does work. With the proxy, I have the following error:</p>
  
  <p><code>A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ...an api...</code></p>
  
  <p>If I try to make an HTTP post in postman app and use the above proxy, it is working. I guess the problem should be on the vb.net code.</p>