Answer the question
In order to leave comments, you need to log in
How to get a response from the Kinopoisk server?
I want to write a movie search application. I found the Kinopoisk api, but I don’t really understand how to get a response from the server and how to display any information. The documentation site says
curl -X GET "https://kinopoiskapiunofficial.tech/api/v2.1/films/300" -H "accept: application/json" -H "X-API-KEY: 71c5dd47-2ab2-40d4-bb00-4974097af5b6"
var key = "71c5dd47-2ab2-40d4-bb00-4974097af5b6";
var request = WebRequest.Create("https://kinopoiskapiunofficial.tech/api/v2.1/films/300");
request.ContentType = "application/json";
request.Headers["X-API-KEY"] = key;
request.Method = "POST";
textBox1.Text = Convert.ToString(request.GetResponse());
Answer the question
In order to leave comments, you need to log in
Change method to get
var key = "71c5dd47-2ab2-40d4-bb00-4974097af5b6";
var request = WebRequest.Create("https://kinopoiskapiunofficial.tech/api/v2.1/films/300");
request.ContentType = "application/json";
request.Headers["X-API-KEY"] = key;
request.Method = "GET";
using (var stream = request.GetResponse().GetResponseStream()){
List<byte> buff = new List<byte>();
while (true){
int b = stream.ReadByte();
if(b != -1)
buff.Add((byte) b);
else
break;
}
textBox1.Text = Encoding.UTF8.GetString(buff.ToArray());
}
using (var stream = new StreamReader(request.GetResponse().GetResponseStream()))
textBox1.Text = = stream.ReadToEnd();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question