'Simple HttpRequestMessage but not working

I'm writing a simple dotnet core API, under search controller which like below :

[HttpGet("order")]    
public async Task <Order> SearchOrder(string ordername, int siteid) {
    return await service.getorder(ordername,siteid)
}

The swagger UI where the path https://devehost/search/order test pretty work, but when I use another client to call this api by below

client = new HttpClient {
    BaseAddress = new Uri("https://devehost")
};

var request = new HttpRequestMessage(HttpMethod.Get, "Search/order")  {
    Content = new FormUrlEncodedContent(
        new List<KeyValuePair<string, string>> {
            new("ordername", "pizza-1"),
            new("siteid", "1"),
       })
};

var response = await client.SendAsync(request);

The status code always return bad request. But the postman is work, can I know the problem inside?

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source