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();
}
}
}
فیلم و نمایش تلویزیونی را نمیتوانید پیدا کنید؟ به سیستم وارد شوید تا آن را ایجاد کنید.
آیا میخواهید به این مورد امتیاز دهید یا به فهرست اضافه کنید؟
عضو نیستید؟
پاسخ توسط Travis Bell
در تاریخ اکتبر 20, 2013 ساعت 1:23 ب.ض
Hi Michael,
Thanks for sharing. Those examples are created automatically by Apiary. I'll have to let them know.
پاسخ توسط Michael Welter
در تاریخ اکتبر 20, 2013 ساعت 1:40 ب.ض
Thanks Travis, I wasn't sure how much control you had over it. Feel free to set the status to closed.