title: VB.net - HttpWebRequest POST (login to Instagram.com)
body: <p>I would like to know how will see log into sites like instagram.com, as I have the same question for twitter, my doubt comes when trying to log in by code without the webbrowser using method post in vb.net, trying to use this code returns me on instagram Error 404:</p>
  
  <pre><code>Dim postData As String = "csrfmiddlewaretoken=" &amp; TextBox1.Text &amp; "&amp;username=xxxxx&amp;password=xxxxx"
      Dim tempCookies As New CookieContainer
      Dim encoding As New ASCIIEncoding
      Dim byteData As Byte() = encoding.GetBytes(postData)
      Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("https://instagram.com/accounts/login/"), HttpWebRequest)
      postReq.Method = "POST"
      postReq.KeepAlive = True
      postReq.CookieContainer = cokkie
      postReq.ContentType = "application/x-www-form-urlencoded"
      postReq.Referer = "https://instagram.com/accounts/login/"
      postReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0"
      postReq.ContentLength = byteData.Length
  
      Dim postreqstream As Stream = postReq.GetRequestStream()
      postreqstream.Write(byteData, 0, byteData.Length)
      postreqstream.Close()
      Dim postresponse As HttpWebResponse
      postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
      Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
      Dim thepage As String = postreqreader.ReadToEnd
      RichTextBox1.Text = thepage
  </code></pre>
  
  <p>I get the csrfmiddlewaretoken the instagram page by method get, really do not understand, but I think I read that I must first get a cookie before log in, but really do not know, if anyone can help me I would greatly appreciate</p>