C#C
C#4y ago
Juicy

No route matches supplied values but values seem to match?

Hi I am getting this error on return CreatedAtAction:
System.InvalidOperationException: No route matches the supplied values.

            var response = new UserResponse(
                user.Id,
                user.ProductId,
                user.Username,
                user.Role,
                user.CreatedOnUtc);

            var actionName = nameof(GetByIdAsync);
            var routeValues = new {productId, id = user.Id, cancellationToken};

            return CreatedAtAction(actionName, routeValues, response);

[HttpGet("{id:guid}")]
    public async Task<ActionResult> GetByIdAsync(Guid productId, Guid id,
        CancellationToken cancellationToken = default)
    {


But how are the route values incorrect when im giving it productId and the userId? To note, they also exist in the same controller and user.Id + productId are both guids (productId comes from parameter).Dont really understand what im missing here, let me know if you need me to provide more information
Was this page helpful?