I am building application and one of the features is to provide ids so it could be later processed by API. I have created another Net Core API HttpPost method, like below:
[HttpPost("addapplication")]
public IActionResult AddApplication([FromBody] int[] invoiceIds)
{
int newApplicationId = _applRepository.AddApplication(invoiceIds);
if (newApplicationId == 0)
{
return BadRequest();
}
ClientApplicationDto applicationData = GetApplication(newApplicationId);
return CreatedAtRoute("GetApplication", new { newApplicationId }, applicationData);
}
Pretty similar to how I built another HttpPost
.
However when trying to check it with Postman with below body:
{
"invoiceIds": [5, 6]
}
I get error:
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "|f14e8651-4e050cec0f913d32.",
"errors": {
"$": [
"The JSON value could not be converted to System.Int32[]. Path: $ | LineNumber: 0 | BytePositionInLine: 1."
]
}
}
What am I doing wrong?
asked Dec 13, 2020 at 20:49
1 Answer 1
Well anwser was simple as wrong formulated JSON:
[5,6]
answered Dec 13, 2020 at 21:12
Comments
lang-cs