Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get HTTP Response from a url by using C#

Environment: ASP.Net MVC 4 using C#

I need to get image by using GET request to a 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 it flags "URL not valid"

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

but the result is same

I want to follow this article to receive faxes

Accepting incoming fax notifications by callback

Can anyone help me to get fax...?

like image 991
Lali Avatar asked Apr 03 '13 07:04

Lali


1 Answers

Try like this:

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

Notice how the url is prefixed with the protocol (HTTP in this case). Also make sure you have replaced the {id} part of the url with the actual id of the image you are trying to retrieve.

like image 72
Darin Dimitrov Avatar answered Nov 15 '22 09:11

Darin Dimitrov