Can someone tell us more about the methods of POST sending via httpclient
How many sites I haven't looked at, there are still questions. Here's the code, and it doesn't seem to be correct
string loginURI = "https://www.avito.ru/moskva/avtomobili/hyundai/solaris?radius=200#login?s=h";
var client = new HttpClient();
var result = await client.GetStringAsync(loginURI);
Console.WriteLine(result);
HttpContent content = new StringContent("https://www.avito.ru/api/1/stats/frontend/fps HTTP/1.1");
var a= await client.PostAsync(loginURI, content);
It seems that I write the link and http myself, but in other examples I saw this
var person = new Person ();
person.Name = "Джон Доу";
person.Occupation = "садовник";
var json = JsonConvert.SerializeObject (person);
var data = new StringContent (json, Encoding.UTF8, "application / json");
var url = "https://httpbin.org/post";
использование var client = new HttpClient ();
var response = ожидание клиента. PostAsync (url, data);
Do I have to send json data? Or what, can you point out the errors and explain what and how?
1 answers
You should read something about working with the network, in. NET. For example, " Andrew Krovchik, Vinod Kumar --. Net. Network programming for professionals" :)
In short, the data in the POST request is transmitted in the request body, not in the address bar, and the server does not analyze it, but simply passes it to the addressee. Most often it is JSON, but it is not necessary at all :). The main thing is that the recipient understands what you are sending him.