Reputation: 12862
My webAPI solution currently works if I send a single id to the delete endpoint:
DELETE /api/object/1
With:
[HttpDelete]
public HttpResponseMessage DeleteFolder(int id)
{
// Do stuff
}
In my client application I have a UI that allows for multiple deletes - right now it's just calling this endpoint in a loop for each one of the ids selected, which isn't super performant. I'd like to be able to send an array of Ids to the Delete method in this case... how can this be achieved?
Upvotes: 5
Views: 11577
Reputation: 1038730
[HttpDelete]
public HttpResponseMessage DeleteFolder(int[] ids)
{
// Do stuff
}
and then you could send the following HTTP request:
DELETE /api/somecontroller HTTP/1.1
Accept: application/json
Content-Length: 7
Content-Type: application/json
Host: localhost:52996
Connection: close
[1,2,3]
Upvotes: 5
Reputation: 1671
[HttpDelete]
public HttpResponseMessage Folder([FromUri] int[] ids)
{
//logic
}
api call
DELETE /api/Folder?ids=1&ids=2
Upvotes: 5