KuumaKoira
KuumaKoira
CC#
Created by Very Funny on 11/16/2023 in #help
Unable to find endpoints. Invalid URI
Do your actions (methods in controller that are supposed to be endpoints) have their own routing too? If not, change line
[Route("api/[controller]")]
[Route("api/[controller]")]
To
[Route("api/[controller]/[action]")]
[Route("api/[controller]/[action]")]
Then the routes will default to action naming e.g: Create() will be accessible under api/admin/create unless you overwrite it
5 replies
CC#
Created by Mee6 on 11/13/2023 in #help
Endpoint routing how to support users/me and users/<id>
You can do it in single action in a controller. Something like that (sorry if code will look clumsy, writing it on phone)
[HttpGet("users/{id}/items")]
Public async Task<IActionResult> (string id)
{
if(id == "me") { /* get id of current user from jwt token and items from user with given id*/}
else { /* get items of user with given id */

//Rest of controller body
}
[HttpGet("users/{id}/items")]
Public async Task<IActionResult> (string id)
{
if(id == "me") { /* get id of current user from jwt token and items from user with given id*/}
else { /* get items of user with given id */

//Rest of controller body
}
Would look like that in very simple example
8 replies