Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Visual Basic HTTPWebRequest - get Return Header Response

Posted on 2011-02-10
1
Medium Priority
?
635 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:keith1001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 34865638
After you've written to the request stream, you need to issue the request and get the HttpWebResponse back which you do like:
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
Dim status As HttpStatusCode = response.StatusCode

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question