HTTPStatusCode 404 in production only, why?
winanjaya
146
Reputation points
Hi,
What's wrong with my code below, I have tried it in debug mode and got no 404, but if I run it in production (Linux CentOS 8), it fails with 404 (in my case it always fail on pageNo == 2 (there are actually have 20 pages)
List<Task> tasks = new List<Task>();
_httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Token", token);
int pageNo = 0;
int iStatusCode = 0;
while (true)
{
pageNo++;
iStatusCode = 0;
var url = new Uri(baseAddress + $"/v2.2/sims/?page=" + pageNo.ToString());
await _httpClient.GetAsync(url.ToString()).ContinueWith(async (c) =>
{
var response = c.Result;
HttpStatusCode statusCode = response.StatusCode;
iStatusCode = (int)statusCode;
if (statusCode == HttpStatusCode.OK)
{
response.EnsureSuccessStatusCode();
if (response.IsSuccessStatusCode)
{
JArray ja = new JArray();
string res = await response.Content.ReadAsStringAsync();
ja = JArray.Parse(res);
if (ja.HasValues)
{
// Do array process here
}
}
});
if (iStatusCode == (int)HttpStatusCode.NotFound)
break;
}