Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Response Text From WebClient Object despite receiving an HTTP 409

Status
Not open for further replies.

mateobus

Programmer
Aug 20, 2007
28
US
Hey, I am using a web service which is designed to give an HTTP 409 error in some cases. Along with this 409 error, the service sends an XML payload, which I need to be able to read. My problem is that my application is throwing an exception when I tried to fetch the site. Is there a way around this so that I can analyze the reponse xml despite the 409 error. Thanks in advance, here is the code:

Code:
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        'STEP 1: Create a WebClient instance
        Dim objWebClient As New WebClient()


        'STEP 2: Call the DownloadedData method
        Const strURL As String = "[URL unfurl="true"]http://somesite.com"[/URL]
        Dim aRequestedHTML() As Byte
        Dim strRequestedHTML As String
        Try
            aRequestedHTML = objWebClient.DownloadData(strURL)
            Dim objUTF8 As New UTF8Encoding()
            strRequestedHTML = objUTF8.GetString(aRequestedHTML)
        Catch ex As System.Net.WebException
            'not sure what to do hear to read response...
        End Try
    End Sub
 
forum796

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top