I have an API that I want to test. This is the signature of one method...
[HttpGet("{param}")]
public async Task<IActionResult> Get(string param, string param2)
{
...
}
In the test project I structure the call this way...
HttpClient client = new HttpClient();
string uri = "http://localhost:63779/api/controller_name/param/";
HttpResponseMessage response = await client.GetAsync(uri);
param is part of the route but how do I get param2 to the method?
Pass param2
as query string ti the server. The client code:
HttpClient client = new HttpClient();
string uri = "http://localhost:63779/api/controller_name/param/?param2=SOME_VALUE";
HttpResponseMessage response = await client.GetAsync(uri);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With