Link to home
Start Free TrialLog in
Avatar of keith1001
keith1001Flag for United States of America

asked on

Visual Basic HTTPWebRequest - get Return Header Response

I am trying to get the response code from the following code:  It should return a 204 response, but how do I get the response code?

        Dim myReq As HttpWebRequest = DirectCast(WebRequest.Create(Urlstr), HttpWebRequest)
        myReq.Method = "POST"
        myReq.ContentType = "application/json; charset=utf-8"
        Dim bytes As Byte()
        bytes = Encoding.UTF8.GetBytes(myInspection)
        Dim mylogin As String
        myloginDetails = myUserName & ":" & myPassword
        mylogin = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(myloginDetails))
        myReq.Headers.Add(HttpRequestHeader.Authorization, mylogin)
        objRequestStream = myReq.GetRequestStream()

        objRequestStream.Write(bytes, 0, bytes.Length)
        objRequestStream.Close()

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial