Isn't request.PreAuthenticate = true functionally equivalent to adding the credentials manually to avoid the double calls?
On Apr 5, 1:21 am, James Deville <[email protected]> wrote: > Look at what requests you are sending with Netmon or Wireshark. With Witty > (C# wpf app), we discovered that first an unauthenticated request is sent to > find out what auth the server takes, then a authenticated request after > that. This doesn't work on some of the API requests. The solution is to > manually attach the BasicAuth header. > > JD > > On Sat, Apr 4, 2009 at 11:38 AM, DIENECES <[email protected]> wrote: > > > Any idea why I'm forbidden? > > Thanks in advance! > > Function writeMessage(ByVal StrPass, ByVal StrUser, ByVal StrMessage, > > ByVal StrTo) As String > > Dim req As System.Net.HttpWebRequest = > > System.Net.HttpWebRequest.Create("http://twitter.com/direct_messages/ > > new.xml?user= <http://twitter.com/direct_messages/%0Anew.xml?user=>" + > > StrTo + "&text=" + StrMessage) > > If Not StrUser = "" Or StrPass = "" Then > > req.Credentials = New System.Net.NetworkCredential > > (StrUser, StrPass) > > req.Method = "POST" > > 'req.ContentLength = 0 > > 'req.ServicePoint.Expect100Continue = False > > req.ContentType = "application/x-www-form-urlencoded" > > 'req.PreAuthenticate = True > > Dim resp As HttpWebResponse = req.GetResponse() > > Dim sr As New System.IO.StreamReader(resp.GetResponseStream > > ()) > > 'sr.Read(req.GetResponse(), ) > > Return sr.ReadToEnd() > > End If > > > End Function
