Creating a POST method and testing for Postman , I can not access the Controller of this POST . I did not implement a lot yet, but I should stop at Break if, of course, it was working. Controller
[Route("api/[controller]")]
public class OptOutClientController : Controller
{
private IOptOutCreateService optOutCreateService;
HttpClient httpClient = new HttpClient();
public OptOutClientController(IOptOutCreateService optOutCreateService)
{
this.optOutCreateService = optOutCreateService;
}
[HttpPost]
public async Task<IActionResult> OptOutPostClient([FromBody]OptOutRequest client)
{ **Breakpoint nessa chave e não entra **
if (client == null)
throw new OptOutException( "Favor informar os dados do OptOut!");
var result = await optOutCreateService.Process(new OptOutCreateCommand(client.Cpf, client.Email, client.Telefone, client.Bandeira, client.Canal));
return Ok(new ApiReturnItem<OptOutResult> { Item = result, Success = true });
}
}
Postman Screenshot running POST
EDIT1
Imadeasmallexamplewithnothing,justacontrollerandnothingelseandIhavethesameerror:Startup.cs
publicclassStartup{publicvoidConfigureServices(IServiceCollectionservices){services.AddMvc();services.AddRouting();}//Thismethodgetscalledbytheruntime.UsethismethodtoconfiguretheHTTPrequestpipeline.publicvoidConfigure(IApplicationBuilderapp,IHostingEnvironmentenv){app.UseMvc(routes=>{routes.MapRoute(name:"default",
template: "{controller=Home}/{action=Index}");
});
}
}
controller
[Route("api/[controller]")]
public class HomeController : Controller
{
[HttpPost]
public IActionResult postar()
{
return Ok();
}
}
Postman url: link body: {"test": "1"}
And I get the same error as page not found