0

I'm trying to connect to TNT's server for making XML request.

First I'm trying to just make a successful connection (before trying to send anything).
According to TNT everything is set up ok. So I'm thinking it's on my end.
I'm using the code below. But it just comes back with, that it's unauthorized.

Dim request As WebRequest = WebRequest.Create("https://express.tnt.com/expressconnect/track.do?version=3")
Dim authInfo As String = ("username" + (":" + "password"))
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo))

request.Headers("Authorization") = ("Basic " + authInfo)
request.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested
request.ContentType = "application/x-www-form-urlencoded"
request.Method = "POST"

Try
    Dim response As WebResponse = request.GetResponse
    Console.Write(response)
Catch ex As Exception
    Console.WriteLine(ex.Message)
End Try
Console.ReadLine()

Can anyone help or shed any light on what i am doing wrong?

GSerg
  • 76,472
  • 17
  • 159
  • 346
Crampo
  • 73
  • 1
  • 6
  • Does it work if you try those credentials in Postman ? – auburg Feb 11 '20 at 09:39
  • Does this answer your question? [HttpWebRequest using Basic authentication](https://stackoverflow.com/questions/4334521/httpwebrequest-using-basic-authentication) – GSerg Feb 11 '20 at 09:40

0 Answers0