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?

1 Answer 1

1

Well anwser was simple as wrong formulated JSON:

[5,6]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.