0
I am starting my studies with REST API and following an Internet tutorial I developed this API :
Class :
namespace SimpleRESTServer.Models
{ public class Person { public long ID { get; set; } public String Lastname { get; set; } public String Fisrtname { get; set; } public Double Payrate { get; set; } public Datetime Startdate { get; set; } public Datetime Enddate { get; set; } } }
Controller :
namespace SimpleRESTServer.Controllers
{ public class Personcontroller : Apicontroller { // GET: api/Person public Ienumerable Get() { Return new string[] { "Person1", "Person2", "É nois Mano" }; }
// GET: api/Person/5
public Person Get(int id)
{
Person person = new Person();
person.ID = id;
person.LastName = "Da Silva";
person.FisrtName = "Eduardo";
person.PayRate = 45.54;
person.StartDate = DateTime.Parse("5/5/2019");
person.EndDate = DateTime.Parse("5/10/2019");
return person;
}
// POST: api/Person
public void Post([FromBody]Person value)
{
//PersonPersistence pp = new PersonPersistence();
//long id;
//id = pp.savePerson(value);
}
// PUT: api/Person/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE: api/Person/5
public void Delete(int id)
{
}
}
}
And I’m using POSTMAN to test it and fill out POSTMAN according to the screen below.
It turns out that the information is not coming in the Controller when I debug the content it is always NULL
Does anyone have any idea what might be wrong..???
Thank you
Thanks Carlos. I switched to [Fromuri] as you suggested and worked.
– Eduardo