I am developing a WebApi endpoint for a client application. The API has a method with the following signature:
public async Task<IHttpActionResult> Post([FromBody] int[] employeeIds)
The sample POST-request I use to trigger this endpoint:
Authorization: Bearer [token]
Host: localhost:44301
Content-Length: 16
Content-Type: application/json
[10,20,30,40,50]
This all works fine and dandy. The problem is that the client application can only send key/value pairs. As you can see from the sample POST-request, I am only sending the value of the array.
The only solution I can think of is to define a model with the array as a property, but this adds a new class to my codebase with no other purpose than being a container.
How do I overcome this problem?
Edit
I'm looking for a solution that allows the client to send the array as the value component of a key/value pair:
key = [10, 20, 30, 40, 50]
How can I transform my method into accepting such a request?