Написал код который отправляет запрос на
этот сайт.
Но почему-то просто все зависает...
using System;
using System.Net.Http;
using System.Windows.Forms;
using System.Text.Json;
using System.Threading.Tasks;
namespace WinFormsApp4
{
public partial class Form1 : Form
{
string Address = "https://kad.arbitr.ru/Kad/SearchInstances";
class Search {
public int Page { get; set; }
public int Count { get; set; }
public string[] Courts { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public Sides[] Sides { get; set; }
public Judges[] Judges { get; set; }
public string[] CaseNumbers { get; set; }
public bool WithVKSInstances { get; set; }
}
class Sides
{
public string Name { get; set; }
public int Type { get; set; }
public bool ExactMatch { get; set; }
}
class Judges
{
public string JudgeId { get; set; }
public int Type { get; set; }
}
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Search search = new Search()
{
CaseNumbers = Array.Empty<string>(),
Page = 1,
Count = 25,
Courts = Array.Empty<string>(),
DateFrom = null,
DateTo = null,
Sides = Array.Empty<Sides>(),
Judges = Array.Empty<Judges>(),
WithVKSInstances = false
};
try
{
var response = PostRequest(search);
label2.Text += response.Result.ToString();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private async Task<HttpResponseMessage> PostRequest(Search data)
{
Uri uri = new Uri(Address);
HttpContent content = new StringContent(JsonSerializer.Serialize(data));
HttpClient http = new HttpClient();
return await http.PostAsync(uri, content);
}
}
}