5

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...?

1
  • Have you tried prefixing the URL with the protocol (http://) and suffixing it with the file extension of the image (.jpg, .png etc)? Commented Aug 29, 2013 at 16:00

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.