C
C#16mo ago
GilliamII

❔ ✅ Swagger not sending Guid string correctly

Hello all, I have a controller set up exactly the same as some other controllers to get an item by an id but when I send the id in with swagger it is not working correctly. Here is an image of the problem: I am stumped on why this is happening. Anyone know what is going wrong? Thank you!
7 Replies
cap5lut
cap5lut16mo ago
what does the controller's endpoint look like?
GilliamII
GilliamIIOP16mo ago
[HttpGet]
[Route("{id:Guid}")]
public async Task<IActionResult> GetById ( [FromRoute] Guid Id )
{
var walkDomainModel = await walkRepository.GetByIdAsync(Id);
if (walkDomainModel == null)
{
return NotFound();
}

var walkDto = mapper.Map<WalkDto>(walkDomainModel);

return Ok(walkDto);
}
[HttpGet]
[Route("{id:Guid}")]
public async Task<IActionResult> GetById ( [FromRoute] Guid Id )
{
var walkDomainModel = await walkRepository.GetByIdAsync(Id);
if (walkDomainModel == null)
{
return NotFound();
}

var walkDto = mapper.Map<WalkDto>(walkDomainModel);

return Ok(walkDto);
}
cap5lut
cap5lut16mo ago
its the difference between id and Id in the route and in the parameter list
GilliamII
GilliamIIOP16mo ago
thank you
cap5lut
cap5lut16mo ago
please dont forget to $close the thread to mark it as answered
MODiX
MODiX16mo ago
Use the /close command to mark a forum thread as answered
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?