While any developer will be able to fix the error I thought you may want to fix your API documentation for C#. The below will produce a runtime error.
var request = System.Net.WebRequest.Create("http://themoviedb.apiary.io/3/movie/{id}") as System.Net.HttpWebRequest;
request.Method = "GET";
request.Headers.Add("Accept", "application/json");
request.ContentLength = 0;
string responseContent;
using (var response = request.GetResponse() as System.Net.HttpWebResponse) {
using (var reader = new System.IO.StreamReader(response.GetResponseStream())) {
responseContent = reader.ReadToEnd();
}
}
Fix:
var request = System.Net.WebRequest.Create("http://themoviedb.apiary.io/3/movie/{id}") as System.Net.HttpWebRequest;
request.Method = "GET";
request.Accept = "application/json";
request.ContentLength = 0;
string responseContent;
using (var response = request.GetResponse() as System.Net.HttpWebResponse) {
using (var reader = new System.IO.StreamReader(response.GetResponseStream())) {
responseContent = reader.ReadToEnd();
}
}
Or a more complete example
var request = (HttpWebRequest)WebRequest.Create(string.Format("http://api.themoviedb.org/3/movie/{1}?api_key={0}", ApiKey, tmdb));
request.Method = "GET";
request.Accept = "application/json";
request.Headers.Add("Accept-Charset", "UTF-8");
request.ContentLength = 0;
string json;
using (var response = request.GetResponse() as HttpWebResponse)
{
if (null != response && HttpStatusCode.OK == response.StatusCode)
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
json = reader.ReadToEnd();
}
}
}
Can't find a movie or TV show? Login to create it.
Want to rate or add this item to a list?
Not a member?
Reply by Travis Bell
on October 20, 2013 at 1:23 PM
Hi Michael,
Thanks for sharing. Those examples are created automatically by Apiary. I'll have to let them know.
Reply by Michael Welter
on October 20, 2013 at 1:40 PM
Thanks Travis, I wasn't sure how much control you had over it. Feel free to set the status to closed.