Im POSTing some data via Angular 6, but my Core API keeps returning nulls:
Request:
{"id":0,"name":"test","weight":2,"frequency":2,"activityTypeModelId":3}
Response:
{id: 0, name: null, weight: 0, frequency: 0, activityTypeModelId: 0}
Controller:
[HttpPost("[action]")]
public IActionResult Add([FromForm]Model model)
{
return new JsonResult(model);
}
Angular, using HttpClient:
add(Model: model) {
return this.http.post(this.addUrl, model);
}
API Model:
public class Model
{
[Key]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public int Weight { get; set; }
public int Frequency { get; set; }
public int ActivityTypeModelId { get; set; }
}
TS Model:
export class Model{
id?: number;
name?: string;
weight?: number;
frequency?: number;
activityTypeModelId?: number;
}
Everything works fine when I'm using Postman. I already tried with [FromBody]. Where is the problem?
newCircumstance, what is that?request bodyover there?