When testing a specific API I had to check if the user was redirected to the correct location. However although I thought that I had written my api correctly, the response code didn’t match.
Here is the related test code:
Do you spot my mistake? Let’s have a look at the documentation:
The default HttpClient will automatically handle redirects what makes it impossible to check for the 302 status code
To change this behavior, you need to create your own HttpHandler and use it when building up your HttpClient instance: