У меня есть этот контроллер:
namespace Cantrel.Application.CantrelSearchApi.Controllers
{
[Route("api/[controller]")]
[Authorize]
public class MonitorsController : Controller
{
private readonly IMonitoringApiService monitoringService;
private readonly IClientsApiService clientsService;
private readonly ILogger<MonitorsController> logger;
public MonitorsController(IMonitoringApiService monitoringService,
IClientsApiService clientsService,
ILogger<MonitorsController> logger)
{
this.monitoringService = monitoringService;
this.clientsService = clientsService;
this.logger = logger;
}
[HttpGet("{id}")]
public async Task<IActionResult> Get(string id)
{
if (string.IsNullOrEmpty(null))
{
return BadRequest("No id was provided. Please provide a valid monitor id or subject id.");
}
try
{
MonitorDto monitor;
if (Guid.TryParse(id, out Guid monitorId))
{
monitor = await GetByMonitorId(monitorId);
}
else
{
monitor = await GetBySubjectId(id);
}
if (monitor == null)
{
return NotFound();
}
return Json(monitor);
}
catch (Exception ex)
{
logger.LogError($"[{Request.Path.Value}]: {ex.ToString()}");
return new StatusCodeResult(500);
}
}
Я делаю следующий звонок в Почтальоне:
GET: {{api}}/Monitors/ABCDEFGH-1234-4567-8901-ABCDEFGHIJKL
Вместо ожидаемого возврата информации на этом мониторе я получаю ошибку 400 Bad Request
с сообщением No id was provided. Please provide a valid monitor id or subject id
.
Я не уверен, что понимаю, как это происходит. Строка явно не пуста и не пуста.
Пожалуйста, дайте мне знать, если есть какой-либо другой код класса, который я должен предоставить, чтобы помочь в диагностике.