I have an ASP.NET Core 1.1 Web API. I have a very simple DTO:
public class ItemsDto { public int? ItemId { get; set; } public int? Quantity { get; set; } }
And a controller action:
[HttpPost("{propertyId}/items")] [Authorize] public async Task<IActionResult> PostPropertyItems([FromRoute] int propertyId, [FromBody] ItemsDto[] items) { if (!ModelState.IsValid) return BadRequest(ModelState); // Some code }
When I post this using PostMan:
[{"itemId":121,"quantity":0},{"itemId":122,"quantity":1},{"itemId":117,"quantity":0},{"itemId":100,"quantity":2},{"itemId":7,"quantity":2},{"itemId":118,"quantity":0},{"itemId":119,"quantity":0},{"itemId":120,"quantity":1}]
It works perfectly. But when our other developoer posts the same thing from his IONIC2 app, all ItemIds are NULL as soon as the action is triggered. The "quantities" are all populated, but the "itemIds" are all NULL. Yet ModelState.IsValid = true
Any ideas?