السلام عليكم ورحمة الله وبركاته

لدي مشكله غريبه شوي تتعلق في Httpwebrequest رسالة الخطأ

Additional information: Object reference not set to an instance of an object.

اريد حساب طول البوست المرسل بعد ان يتم جلب التوكن (Token) في موقع تويتر ومن ثم يرسله مع بارمترات بوست اليوزرنيم والباسورد والايميل وغيره وبعدين يحسب الطول للبايتات في الهيدر request.ContentLength = byteData.Length هنا الكود يوضوح اكثر

Sub Signup()

'' make request for Twitter Page signup

Dim url As String = "https://twitter.com/signup"
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
request.SendChunked = True
request.Method = "POST"
request.KeepAlive = True
request.CookieContainer = tmpcookie
request.ContentType = "application/x-www-form-urlencoded"
request.Referer = "https://twitter.com/signup"
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0"
request.Accept = "*/*"
  request.ContentLength = byteData.Length 'هنا المشكله اللي جننتني

'' make resonse

Dim res As WebResponse = request.GetResponse
' make streamreader for get randomize token in field "authenticity_token"
Dim sr As New StreamReader(res.GetResponseStream())
Dim final As String = sr.ReadToEnd()

' Dim postreq As Stream = request.GetRequestStream()
'   postreq.Write(byteData, 0, byteData.Length)
'postreq.Close()


'regex for find patern the token
Dim r As New Regex("<input type=""hidden"" name=""authenticity_token"" value="".*""")
' array 
Dim ms As MatchCollection = r.Matches(final)

'loop
For Each m As Match In ms

    ' clear the result (html tags and son on )
    Dim extract_r As New Regex("value="".*""")
    Dim extract_m As Match = extract_r.Match(m.Value)
    Dim token As String = extract_m.Value


    token = token.Replace("value=", "")
    token = token.Replace("""", "")

    ' store cleaned result in variabl

    final1 = token

    ' post data with token to URL 
    Dim PostData As String = "authenticity_token=" & token & "&user%5Bname%5D=amroooo6565+&user%5Bemail%5D=mooosd565osa%40ff5ffds.com&user%5Buser_password%5D=123123a&user%5Bscreen_name%5D=abohhhgf55gyfyf&asked_cookie_personalization_setting=1&context=&ad_id=&ad_ref=&user%5Bremember_me_on_signup%5D=1&user%5Bdiscoverable_by_email%5D=1&user%5Bsend_email_newsletter%5D=1"
    byteData = encoding.GetBytes(PostData)

    'resonse for result signup
    Dim postresonse As HttpWebResponse
    postresonse = DirectCast(request.GetResponse(), HttpWebResponse)
    tmpcookie.Add(postresonse.Cookies)
    signupcookie = tmpcookie

    'read resonse from server 
    Dim postreqreader As New StreamReader(postresonse.GetResponseStream)
    Dim page As String = postreqreader.ReadToEnd

    ' find correct text in page if find it mean succssed

    If page.Contains("We’re glad you’re here") Then

    End If

    ' postreqreader.Close()

    ' Console.Write(token)

    'Thread.Sleep(4000)


Next

End Sub