Get HTTP response from url using C #

Environment: ASP.Net MVC 4 using C #

I need to get the image using the GET request for the URL /inbound/faxes/{id}/image I used the code below

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("/inbound/faxes/238991717/image");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

System.IO.StreamReader stream = new StreamReader(response.GetResponseStream());

but the URL is invalid checkbox

I used the full URL www.interfax.net/inbound/faxes/{id}/image

but the result is the same

I want to follow this article to receive faxes

Receive incoming fax messages using a callback

Can someone help me get a fax ...?

+5
source share
1 answer

Try it like this:

using (var client = new WebClient())
{
    byte[] imageData = client.DownloadData("http://www.interfax.net/inbound/faxes/{id}/image");
}

Note that the URL has a protocol prefix (in this case HTTP). Also, make sure you replace the portion of the {id}URL with the actual identifier of the image you are trying to retrieve.

+6
source

All Articles