Question

I'm trying to view the HTTP request being sent/received to twitter. I tried downloading fiddler4 but it's not registering the 401 error and I'm only receiving the 500 page error. Any ideas on how to view the request being sent so I can trouble shoot the reason?

I tried viewing the site as localhost, 127.0.0.1, and machinename.

Dim oAuthRequest As New Dictionary(Of String, String)
                oAuthRequest.Add("resource_url", "https://api.twitter.com/oauth/request_token")
                oAuthRequest.Add("oauth_callback", Server.UrlEncode("https://www.site.com/callback/"))
                oAuthRequest.Add("oauth_consumer_key", "xxxxxxxx")
                oAuthRequest.Add("oauth_nonce", Convert.ToBase64String(New ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString())))
                oAuthRequest.Add("oauth_signature_method", "HMAC-SHA1")
                oAuthRequest.Add("oauth_timestamp", CInt((DateTime.UtcNow - New DateTime(1970, 1, 1)).TotalSeconds).ToString)
                oAuthRequest.Add("oauth_token", "authorization_code")

Dim baseFormat As String = "oauth_callback=""{0}""&oauth_consumer_key=""{1}""&oauth_nonce=""{2}""&oauth_signature_method=""HMAC-SHA1""&oauth_timestamp=""{3}""&oauth_version=""" & Uri.EscapeDataString("1.0") & """"
Dim baseString As String = String.Format(baseFormat,
    oAuthRequest("oauth_callback"),
    oAuthRequest("oauth_consumer_key"),
    oAuthRequest("oauth_nonce"),
    oAuthRequest("oauth_timestamp"))

                baseString = String.Concat("POST&", Uri.EscapeDataString(oAuthRequest("resource_url")), "&", Uri.EscapeDataString(baseString))
                oAuthRequest.Add("oauth_signature", SHA1Base64Hash("xxxxxxx&", baseString))

Dim authHeaderFormat As String = "OAuth oauth_callback=""{0}"",oauth_consumer_key=""{1}"",oauth_nonce=""{2}"",oauth_signature=""{3}"",oauth_signature_method=""HMAC-SHA1"",oauth_timestamp=""{4}"",oauth_version=""1.0"""

Dim authHeader As String = String.Format(authHeaderFormat,
            Uri.EscapeDataString(oAuthRequest("oauth_callback")),
            Uri.EscapeDataString(oAuthRequest("oauth_consumer_key")),
            Uri.EscapeDataString(oAuthRequest("oauth_nonce")),
            Uri.EscapeDataString(oAuthRequest("oauth_signature")),
            Uri.EscapeDataString(oAuthRequest("oauth_timestamp")))


                ServicePointManager.Expect100Continue = False
Dim request As HttpWebRequest = CType(WebRequest.Create(oAuthRequest("resource_url")), HttpWebRequest)
                request.Headers.Add("Authorization", authHeader)
                request.Method = "POST"
                request.ContentType = "application/x-www-form-urlencoded"
                Try
Dim response As WebResponse = request.GetResponse()
                Catch ex As Exception
                    Text.text = ex.Message
                End Try
Was it helpful?

Solution

If Fiddler shows you a HTTP/500 rather than a HTTP/401, that's because the server is returning HTTP/500. Unless you tell it to do so, Fiddler does not invent responses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top