I'm trying to fill in an ICollection type that is owned by my Professional template.
When executing the request I pass the information via JSON
ButintheVSandGETdebugtheinformationisnotthere!
Do as Maycon quoted, your object must have the same name with the same property with identical names that will work.
The name of the properties of your json
can be equal to the object you are receiving as already quoted (I think this is particularly horrible, rs). I'll show you a more "elegant" way of solving, using Newtonsoft.Json
.
First instantiate it in your project:
using Newtonsoft.Json;
Then on your object
public class RootObject
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("lastname")]
public string Lastname { get; set; }
[JsonProperty("cpf")]
public string Cpf { get; set; }
[JsonProperty("birthDate ")]
public string BirthDate { get; set; }
[JsonProperty("motherName")]
public string MotherName { get; set; }
[JsonProperty("postalCode")]
public string PostalCode { get; set; }
[JsonProperty("adress")]
public string Adress { get; set; }
[JsonProperty("adressNumber")]
public string AdressNumber { get; set; }
[JsonProperty("complement")]
public string Complement { get; set; }
[JsonProperty("background")]
public string Background { get; set; }
[JsonProperty("graduations")]
public IEnumerable<Graduation> Graduations { get; set; }
}
public class Graduation
{
[JsonProperty("instituionName")]
public string InstituionName { get; set; }
[JsonProperty("grade")]
public string Grade { get; set; }
[JsonProperty("formationYear")]
public string FormationYear { get; set; }
}
Your Controller
[HttpPost]
public IActionResult Create([FromBody] RootObject obj)
{
// Faz algo aqui
return Ok();
}
And finally have the long awaited result, hehe.