401 unauthorized
Posted: Sat Jan 12, 2019 10:18 am
Hi
Am trying to activate shipment and it returns with 401 unauthorized, am using the below code, is there an example where I can provide the authentication too? Pls advise
Dim request As WebRequest = WebRequest.Create(String.Format(My.Settings.loginAPIServer) + "Shipments/Activate/{" + _ShipmentID + "}")
request.Method = "POST"
request.ContentLength = 0
Dim response As WebResponse = request.GetResponse()
Dim dataStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
Dim jss As New JavaScriptSerializer
Dim val As apiLoginResponse = jss.Deserialize(Of apiLoginResponse)(responseFromServer)
reader.Close()
response.Close()
Note, have also tried the array option too , as below
'Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData)
'request.Method = "POST"
'request.ContentType = "application/x-www-form-urlencoded"
'request.ContentLength = byteArray.Length
Am trying to activate shipment and it returns with 401 unauthorized, am using the below code, is there an example where I can provide the authentication too? Pls advise
Dim request As WebRequest = WebRequest.Create(String.Format(My.Settings.loginAPIServer) + "Shipments/Activate/{" + _ShipmentID + "}")
request.Method = "POST"
request.ContentLength = 0
Dim response As WebResponse = request.GetResponse()
Dim dataStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
Dim jss As New JavaScriptSerializer
Dim val As apiLoginResponse = jss.Deserialize(Of apiLoginResponse)(responseFromServer)
reader.Close()
response.Close()
Note, have also tried the array option too , as below
'Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData)
'request.Method = "POST"
'request.ContentType = "application/x-www-form-urlencoded"
'request.ContentLength = byteArray.Length