I have this simple request to XTB broker demo account according to the documentation http://developers.xstore.pro/documentation/
public static async Task Login()
{
var httpClient = new HttpClient();
using StringContent jsonContent = new(
JsonSerializer.Serialize(new
{
command = "login",
arguments = new
{
userId = "XXXX",
password = "XXXX",
}
}),
Encoding.UTF8,
"application/json");
var uri = new Uri("https://xapi.xtb.com:5124");
using HttpResponseMessage response = await httpClient.PostAsync(
uri,
jsonContent);
var jsonResponse = await response.Content.ReadAsStringAsync();
Console.WriteLine($"{jsonResponse}\n");
}
But I am always getting error:
"IOException: The response ended prematurely."
What I found on the internet is that I need to use ssl connection for request to work, but I am not sure how to implement it inside this avalonia .net project. Is there any way way how can I make ssl request?
http://developers.xstore.pro/documentation/
So that means that You cannot use HTTP request, seems that raw socket + SSL stream need to be used. I created code snipped to give idea how probably it should work:
I get following output:
Regards NeuroXiq