C#C
C#3y ago
18 replies
dotnet123123

✅ ✅ C# HttpClient returning 400, but other tools return 200

I am trying to make a simple web request to a URL using .NET/C# HttpClient. I am getting a 400 error "Bad Request". Whereas everything else such as Python Requests, Postman, and the Web browser dev tools all return a 200 Success.

The URL is http://ericsmithrocks.com. This is a random URL I found that exhibits this behavior. Other URLs seem to work as expected.

I have experimented with replacing "http" with "https" and adding an HttpClientHandler with different settings, with no success.

I am thinking it may be something to do with my headers or an http permanent redirect issue.

Any help would be greatly appreciated. I have attached pictures of all my code / tests. Thanks.
dotnet_code_VS.png
python_requests.png
firefox_network_tab.png
postman.png
ERIC SMITH
Was this page helpful?