0

I am developing an asp.net mvc web application in which I need to call OMDB api (an api to get Imdb information of a movie). I need to send a simple GET request to the api and get the response(movie details), deserialize the response into an object and pass it to the view. Is this possible without using a reference to an external library? Can anybody give me an example on how to do it inside a controller action.

1 Answer 1

2

You can use the WebRequest class

using System.Net;

string url = "https://www.service.com?param=movieName";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Stream responseStream = response.GetResponseStream();

Reference:

http://support.microsoft.com/kb/307023

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

1 Comment

thanks for the answer and it worked well! I used StreamReader class to read the responseStream.

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.