I have one api method,i pass "/api/stocks/1/images/" and list of stockimage as json. I am getting stockImages below as null (function's input parameter)
[Route("api/stocks/{stockId}/images")]
public IHttpActionResult Post(int stockId, [FromBody]List<StockImage> stockImages)
{
return Ok();
}
When i pass /api/stocks/1/images/ and list of stockimage as json and wrap it in a class and not accept list directly, I am able to see stockImages prefilled (function's input parameter)
I have one api method
[Route("api/stocks/{stockId}/images")]
public IHttpActionResult Post(int stockId, [FromBody]Temp stockImages)
{
return Ok();
}
public class Temp
{
public List<StockImage> stockImages {get; set;}
}
Do i need to have this Temp wrapper class or is there any way to avoid this?
Adding sample json:
{
"stockImages":[
{
"imgId" : 8908,
"imgURL": "http://imgd5.aeplcdn.com/cw/Volkswagen-Polo-Comfortline-4319619.jpg",
"altText":"Honda City Exterior Photos",
"title":"Honda City Exterior Photos",
"defaultImg":true
}
]
}
{[ { "imgId" : 8908, "imgURL": "http://imgd5.aeplcdn.com/cw/Volkswagen-Polo-Comfortline-4319619.jpg", "altText":"Honda City Exterior Photos", "title":"Honda City Exterior Photos", "defaultImg":true } ]}