I'm trying to use HttpClient to get html content of a page. to try the method I tested with the google URL, and it's working, I receive the content of my html page. but with url I want, impossible to get a content. I have each time a return code http 500. the problem is that, I can get the content of my file with POSTMAN or even with python but impossible with .NET5
does anyone have an idea ? thank you in advance.
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
try
{
HttpResponseMessage response = await client.GetAsync("https://www.naeu.playblackdesert.com/fr-FR/Adventure/Profile?profileTarget=tbXSK7e39Sb3U3yPi7UDjjSeXLzr0HZbr%2bvZQYvtEENKNEz6zPFwtpkvp0pIir%2fk%2fWk7JFLXKICyzqEBwajIrTCHQPFH4MRyBkor2fVeMAb8hNGoasy8HtBiHlcoWN1xRsmmYjVt6WbJg2ocvr%2fbsQk2sbjKeD5a7VqgreAH0ztzMvoFqk7Z%2fZ7L4USyu5Up");
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
Specify the User-Agent like this.
Before the line HttpResponseMessage response = await client.GetAsync