The remote server returned an error: (407) Proxy Authentication Required.

Mar 26, 2008 at 10:41 AM
Edited Mar 26, 2008 at 11:23 AM
I came accorss this error while at work but is easly sorted.
Just changed the function "GetQueryResponse" to the following. would be useful if you could include this within the next version. Just have a few extra properties on the FacebookService control for username, password, proxy

Friend Shared Function GetQueryResponse(ByVal requestUrl As String, ByVal postString As String) As String
' Create a web request for input path.
Dim webRequest As WebRequest = webRequest.Create(requestUrl)
webRequest.Method = "POST"
webRequest.ContentType = "application/x-www-form-urlencoded"

'Create a new Proxy
Dim myProxy As New WebProxy()
'set the address and port of proxy
Dim newUri As New Uri("http://10.4.10.53:8080")
' Associate the newUri object to 'myProxy' object so that new myProxy settings can be set.
myProxy.Address = newUri
' Create a NetworkCredential object and associate it with the Proxy property of request object.
myProxy.Credentials = New NetworkCredential("username", "password", "domain")
'set the webRequest Proxy to our new proxy
webRequest.Proxy = myProxy

If (Not String.IsNullOrEmpty(postString)) Then
Dim parameterString As Byte() = Encoding.ASCII.GetBytes(postString)
webRequest.ContentLength = parameterString.Length

Using buffer As Stream = webRequest.GetRequestStream()
buffer.Write(parameterString, 0, parameterString.Length)
buffer.Close()
End Using
End If

Dim webResponse As WebResponse = webRequest.GetResponse()

Dim responseData As String
Using streamReader As StreamReader = New StreamReader(webResponse.GetResponseStream())
responseData = streamReader.ReadToEnd()
End Using
Return responseData
End Function


Cheers Kev