Unable to fetch API response

I have taken clone from your code samples in C# .Net Core and I have authenticated via your code and [HttpGet("{id}")]
public async Task<IActionResult> GetById(string id, CancellationToken cancellationToken)
{
try
{
var model = await _constituentsService.GetConstituentAsync(id, cancellationToken);
return Ok(model);
}
catch (UnauthorizedAccessException)
{
return RedirectToAction("LogIn", "Authentication");
}
} public async Task<ConstituentModel> GetConstituentAsync(string id, CancellationToken cancellationToken)
{
var httpClient = await GetClient(cancellationToken);
var response = await httpClient.GetAsync($"constituents/{id}", cancellationToken);
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
{
return null!;
}

if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
{
throw new UnauthorizedAccessException();
}

response.EnsureSuccessStatusCode();

var model = await response.Content.ReadFromJsonAsync<ConstituentModel>(cancellationToken: cancellationToken);

return model;
} (function () {
'use strict';

// Check user access token.
fetch('/auth/authenticated')
.then(response => response.json())
.then(data => {
if (data.authenticated === false) {
document.getElementById('login-section').style.display = 'block';
document.getElementById('loading-message').style.display = 'none';
return;
}

// Access token is valid. Fetch constituent record.
fetch('/api/constituents/280')
.then(response => response.json())
.then(data => {
document.getElementById('constituent-name').textContent = data.name;
document.getElementById('constituent-id').textContent = data.id;
document.getElementById('constituent-type').textContent = data.type;
document.getElementById('constituent-lookup-id').textContent = data.lookup_id;
document.getElementById('constituent-first').textContent = data.first;
document.getElementById('constituent-last').textContent = data.last;
document.getElementById('login-section').style.display = 'none';
document.getElementById('constituent-data').style.display = 'block';
document.getElementById('loading-message').style.display = 'none';
})
.catch(error => {
document.getElementById('constituent-error').textContent = 'Error fetching constituent data: ' + error;
document.getElementById('constituent-error').style.display = 'block';
document.getElementById('loading-message').style.display = 'none';
});
}); for constitutent id is hardcoded as 280 and response is coming like this System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() why coming like this?