I have an api (post method) that takes in a list of transport objects. when I test using swagger, the list comes back with a count of 0 (not null), even though I am sending a List of transports. In below scenario I would assume the count should be 1. Here is a small sample of the Json I am sending.
[{
"type": "",
"attributes": {
"TransportId":"",
"Status": "string",
"Action": "test",
"ActionBy": "string",
"ActionDate": "",
"PackingGroupID": "a713eb0a-5682-4cb5"}]
Here is the api call:
[HttpPost, Route("bulk")]
[ResponseType(typeof(List<Transport>))]
public async Task<IHttpActionResult> SaveTransports([FromBody] List<Transport> transports, string packingGroupId)
{
var resulttransports = await _transportService.SaveTransportsAsync(transports, packingGroupId);
if (resulttransports != null)
ConvertTransportDateToTimezone(ref resulttransports);
return Ok(resulttransports);
}
Bel:ow is an image of result
答案 0 :(得分:1)
尝试在末尾再添加一个}。我使用JsonFormatter始终测试我的JSON。
https://jsonformatter.curiousconcept.com/#
[{
"type": "",
"attributes": {
"TransportId":"",
"Status": "string",
"Action": "test",
"ActionBy": "string",
"ActionDate": "",
"PackingGroupID": "a713eb0a-5682-4cb5"}}]