How to pass array as parameter in asp.net core web api.
I have created a rest api, where i have to pass data as array in below format. but when i pass data using postman i am getting an error.
{ "notificationid": [
"BC716385-5D65-4E0F-8987-070D6C42F629","B4425D6C-1028-4164-8C82-0BB9324F48D8"
]}
how can pass array in rest as parameter?
[HttpPost, Route("MarkAllAsRead")]
public async Task<IActionResult> NotificatiRead([FromBody]string [] NotificationId)
{
try
{
ModelState.Remove("PatientId");
if (!ModelState.IsValid)
{
return BadRequest(new
{
Status = false,
Message = string.Join(Environment.NewLine, ModelState.Values
.SelectMany(x => x.Errors)
.Select(x => x.ErrorMessage))
});
}
var res = await _notificationService.ReadNotificationlist(NotificationId);
return res.Status ? StatusCode(StatusCodes.HTTP_OK, res) : StatusCode(StatusCodes.HTTP_DATANOTMATCHED, res);
}
catch (Exception ex)
{
Logger.AddErrorLog(ControllerContext.ActionDescriptor.ControllerName, "Notificationupdate", User.Identity.Name, ex);
return StatusCode(StatusCodes.HTTP_INTERNAL_SERVER_ERROR, ex.Message);
}
}