Forgive me if this is a dumb question, but I'm just trying the SO API, and have run into a basic problem.
If I enter the following URL in a web browser...
https://api.stackexchange.com/2.3/questions?site=stackoverflow.com
...then I get a JSON response as expected.
If I use the exact same URL in a script (in my case using C#, see below), then the result is a regular SO HTML, whose body contains the following (rest of the HTML omitted as I suspect this is all you need)...
<h1 data-translate="block_headline">Sorry, you have been blocked</h1> <h2 class="cf-subheadline"><span data-translate="unable_to_access">You are unable to access</span> api.stackexchange.com</h2>
I tried adding my API key as a querystring parameter, but it didn't make any difference.
I tried accessing the URL from a private browser window, and got the expected results, so it's not like it picked up on my credentials from another tab.
Anyone able to explain what I'm doing wrong?
Here is the C# code I'm using...
HttpClient client = new(); string uri = "https://api.stackexchange.com/2.3/questions?site=stackoverflow.com"; HttpResponseMessage httpResponse = await client.GetAsync(uri); Console.WriteLine($"Status code: {httpResponse.StatusCode}"); Console.WriteLine($"Response body:\n{await httpResponse.Content.ReadAsStringAsync()}");