-1

I'm trying to make a github OAuth but it needs some post and get responses. so how can I make a get request to a specific url an then get the response in form of json, this is the code that I tried:

Dim logincookie As CookieContainer
    Dim rqtp As Integer
        Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create(TextBox1.Text), HttpWebRequest)
                Dim postData As String = TextBox1.Text
                Dim encoding As New UTF8Encoding
                Dim byteData As Byte() = encoding.GetBytes(postData)
                Dim tempCookies As New CookieContainer
                postReq.Method = "GET"
                postReq.KeepAlive = True
                postReq.CookieContainer = tempCookies
                postReq.ContentType = "application/xml"
                postReq.Referer = TextBox1.Text
                postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
                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)
                tempCookies.Add(postresponse.Cookies)
                logincookie = tempCookies
                Dim postreqreader As New StreamReader(postresponse.GetResponseStream())

                Dim thepage As String = postreqreader.ReadToEnd

                response.Text = thepage
                Clipboard.Clear()
                Clipboard.SetText(thepage)
                MsgBox(thepage, vbInformation + vbOK, "result")

also if you want you can see the repo so you can see the ful project :)

JIST
  • 1,139
  • 2
  • 8
  • 30
sk geek
  • 1
  • 2
  • So are you getting a valid json response back and asking for how to deserilize that? or is there some other problem you're after help with? – Hursey Mar 03 '21 at 22:42

1 Answers1

-1

Ideally deserialize that string to a composite object or to a dymamic object. Your could potentially use JavaScriptSerializer or NewtonSoft library to achieve this and serialize that object to json.

Pramod
  • 103
  • 4