1

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

1

Well anwser was simple as wrong formulated JSON:

[5,6]
answered Dec 13, 2020 at 21:12

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.