0

I am trying to to a WebServiceApi(for phone app) that insert a row into a database but I cant make it works, It doesn't enter in the function.

I am using REST Easy extension of Firefox to call the post service.

I call http://localhost:1717/api/Personas with 3 parameters idSubvario,idPersona,idinstalacion

But the response of the server is that It cant find a resource HTTP that match with the URI, If i change to http://localhost:1717/api/Personas?idSubvario=2&idPersona=2&idInstalacion=5190 It works, 0_o

This is the function of the Controller

[System.Web.Mvc.HttpPost]
[System.Web.Mvc.AllowAnonymous]
public ActionResult PostPersonaSubvariosXIDSubvariosYIDPersona(int idSubvario,int idPersona, short idInstalacion)
{
    BsPersonas bPersonas = new BsPersonas();
    bPersonas.InsertarPersonaSubvario(idSubvario, idPersona, idInstalacion);

    EmptyResult er = new EmptyResult();
    return er;
}

Why it works like a GET petition if I say that is HttpPost?

Jason Evans
  • 28,906
  • 14
  • 90
  • 154
D4rWiNS
  • 2,585
  • 5
  • 32
  • 54
  • 2
    http://localhost:1717/api/Personas :- It means you are calling a function named Personas in your apicontroller .But what i can see here is that your function name is something different .Change that and check. – Vipin Nair Jan 21 '15 at 09:14

1 Answers1

2

Your URL is calling Personas function in apiController.But in your code the function is having some different name .Thats why you are getting the error.Change your function name to Personas.It will work

Vipin Nair
  • 517
  • 4
  • 9
  • 33
  • Thanks for the answer, I changed it to the function but still not working, btw If I change the url to http://localhost:1717/api/Personas?idSubvario=2&idPersona=2&idInstalacion=5190 it works :S – D4rWiNS Jan 21 '15 at 09:24
  • Thats okay.Glad i was able to provide you a help.Please mark if are happy with the answer – Vipin Nair Jan 21 '15 at 09:26
  • But why it works like a GET petition if I say that is HttpPost? – D4rWiNS Jan 21 '15 at 09:30
  • Please check this link for more info http://stackoverflow.com/questions/5332275/httppost-vs-httpget-attributes-in-mvc-why-use-httppost – Vipin Nair Jan 22 '15 at 04:33