Hi
Really need help for API Authorization.
Keep receiving message: “The remote server returned an error: (401) Unauthorized.”
I am using https website for testing.
Code-
Dim wHeader As WebHeaderCollection = New WebHeaderCollection()
wHeader.Clear()
wHeader.Add("Authorization: Basic lWM5fs4x5O_qg9HDPJysyoOOwMSCHyI2me_YFnYP" & ":")
Dim sUrl As String = "https://api.companieshouse.gov.uk/company/07856726"
Dim wRequest As HttpWebRequest = DirectCast(System.Net.HttpWebRequest.Create(sUrl), HttpWebRequest)
wRequest.UseDefaultCredentials = True
wRequest.Headers = wHeader
wRequest.Method = "GET"
Dim wResponse As HttpWebResponse = DirectCast(wRequest.GetResponse(), HttpWebResponse)
Dim sResponse As String = ""
Using srRead As New StreamReader(wResponse.GetResponseStream())
sResponse = srRead.ReadToEnd()
End Using
Label1.Text = sResponse.ToString