I made a service and when I call on the URL , passing the proper parameters, does not work:
Call URL :
http://localhost:9078/api/atualiza/1000012120/teste
My service:
public class AtualizaController : ApiController
{
AutorizadorContext contexto = new AutorizadorContext();
PedidoLiberacao liberacao = new PedidoLiberacao();
[AcceptVerbs("Put")]
public void putItensLiberacao(int id, [FromBody]string value)
{
liberacao.AtualizaLiberacao(id, value);
}
}
This is the method the service calls and upgrades in the DB:
[Route("atualiza/{id}/{value}")]
public void AtualizaLiberacao(int id, string value)
{
var lista = contexto.Liberacoes
.Where(l => l.IdOrcamento == id).ToList();
lista.ForEach(f =>
{
f.FlagLiberacao = 0;
f.AutorizouReceberAtrazado = value;
});
contexto.SaveChanges();
}
You're giving ERROR :
page not found (404)
EDIT2
The error above does not have more, but gives this error (Postman):
{ "Message": "The requested resource does not support the http 'GET' method." }
So my service and method stayed
[RoutePrefix("api/Atualiza")]
public class AtualizaController : ApiController
{
AutorizadorContext contexto = new AutorizadorContext();
PedidoLiberacao liberacao = new PedidoLiberacao();
[Route("{id}/{value}")]
[AcceptVerbs("Put")]
public void putItensLiberacao(int id, [FromBody]string value)
{
liberacao.AtualizaLiberacao(id, value);
}
}
and the
[Route("atualiza/{id}/{value}")]
public void AtualizaLiberacao(int id, string value)
{
var lista = contexto.Liberacoes
.Where(l => l.IdOrcamento == id).ToList();
lista.ForEach(f =>
{
f.FlagLiberacao = 0;
f.AutorizouReceberAtrazado = value;
});
contexto.SaveChanges();
}
In the method I commented the attribute, but the error persists. I put a break point in the service and did not even get in.