Reputation: 27
I have this request
[HttpPost("Authenticate/{deviceIdentifier}")]
public async Task<ActionResult<ServiceResponse<AuthorizedDoorsDto>>> Authenticate(Guid deviceIdentifier)
{
Guid id = Guid.Parse(User.Claims.FirstOrDefault(d => d.Type == ClaimTypes.NameIdentifier).Value);
return Ok(await mainService.Authenticate(id, deviceIdentifier));
}
I'm testing this with Postman and I'm sending this request:
https://localhost:5002/Main/Authenticate?deviceIdentifier=bd78209e-e3a0-4576-a17c-832838ce6495
but I'm getting a 404.
I've another requestin the same controller: this one
//For debugging
[HttpGet("GetAll")]
public async Task<ActionResult<Device>> GetAll()
{
Guid id = Guid.Parse(User.Claims.FirstOrDefault(d => d.Type == ClaimTypes.NameIdentifier).Value);
return Ok(await mainService.GetDevice(id));
}
and it's working fine. So I don't get what is wrong with the first one.
Upvotes: 0
Views: 125
Reputation: 1
Remove the {deviceIdentifier} Parameter from your request path
[HttpPost("Authenticate/{deviceIdentifier}")]
Upvotes: 0
Reputation: 463
The request returns 404 because the endpoint expects deviceIdentifier
argument to be a Path Parameter instead of a Query Parameter.
In this case, you should either change the request url to https://localhost:5002/Main/Authenticate/bd78209e-e3a0-4576-a17c-832838ce6495
or remove this argument from the route to [HttpPost("Authenticate")]
.
Upvotes: 2