I am using httpwebrequest to get a response from a website. In this response I should see an xml. But in my response it just shows me jibberish. I used fiddler to see what I get. I get an encoded response, which I manually need to decode to see the contents(this is in fiddler).
How can I do the same thing in vb.net ?
edit The response comes back as https.
I have tried:
HttpUtility.HtmlDecode(myResult,myStreamwriter)
Dim request As HttpWebRequest = DirectCast(WebRequest.Create("www.url.com/$filetype=xml"), HttpWebRequest)
request.KeepAlive = True
request.UserAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11"
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
request.ContentType = "text/xml, charset=utf-8"
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip,deflate,sdch")
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4")
request.Headers.Set(HttpRequestHeader.AcceptCharset, "ISO-8859-1,utf-8;q=0.7,*;q=0.3")
Using getResponse = request.GetResponse
Dim webServiceResponse = getResponse.GetResponseStream()
Dim xmlreader As New IO.StreamReader(webServiceResponse)
'here is where it shows a really gibberish output
Dim myResult As String = xmlreader.ReadToEnd()
Sounds like you need to decompress the response.
Have you tried HttpWebRequest AutomaticDecompression? http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.automaticdecompression.aspx
httpWebRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;