I’m trying to get a token from Asana through the Oauth authorization process but the request.GetResponse call returns ‘the underlying connection was closed: an unexpected error occurred on a send’. I’ve tried using the same uri that I’ve contructed in code directly in a browser and it works! This is in a ASP.NET project. Any help would be greatly appreciated.
Dim uri As String = String.Format("https://app.asana.com/-/oauth_authorize")
Dim parameters As Dictionary(Of String, Object) = New Dictionary(Of String, Object)
parameters.Add("client_id", thisClientID)
parameters.Add("redirect_uri", thisAppRedirectURL)
parameters.Add("response_type", "token")
parameters.Add("state", "auth")
Dim bodyParameters As List(Of String) = New List(Of String)
For Each kv As KeyValuePair(Of String, Object) In parameters
bodyParameters.Add(String.Format("{0}={1}", HttpUtility.UrlEncode(kv.Key), HttpUtility.UrlEncode(kv.Value.ToString())))
Next
Dim requestBody As String = String.Join("&", bodyParameters.ToArray())
uri = String.Format("{0}?{1}", uri, requestBody)
Dim request As HttpWebRequest = WebRequest.Create(uri)
request.Method = "GET"
request.ContentType = "application/x-www-form-urlencoded"
Dim response As HttpWebResponse = request.GetResponse()