HTTPPOST WebApi Endpoint Misses

I have the following simple HTTPPOST endpoint:

[AllowAnonymous]
[HttpPost]
[Route("forgotPassword")]
public IHttpActionResult ForgotPassword(string userName, string callbackUrl)

If the controller is decorated as follows:

[Authorize]
[RoutePrefix("api/accounts")]
public class AccountsController : ApiController

Now, when I try to check this endpoint in a postman, use the following URL:

http: // localhost: 11217 / api / accounts / forgotPassword

with lines in the body of the message

I get the next return.

{"Message": "No HTTP resource was found matching the URI request ' http: // localhost: 11217 / api / accounts / forgotPassword '.,
" MessageDetail ":" No action was found on the Accounts controller that matches the request. "}

( ). , ,

http://localhost:11217/api/accounts/forgotPassword/test&callbackUrl=local

- ?

0
1

mulitple , DTO,

public class forgetPasswordDTO
{
    public string userName { get; set; }
    public string callbackUrl { get; set; }
}

DTO [FromBody]

[AllowAnonymous]
[HttpPost]
[Route("forgotPassword")]
public IHttpActionResult ForgotPassword([FromBody] forgetPasswordDTO data)

var data = {
    'userName': user,
    'callbackUrl': url
};

.

+2

Source: https://habr.com/ru/post/1660487/


All Articles