如果我将一个id发送到删除端点,我的webAPI解决方案当前有效:
DELETE /api/object/1
使用:
[HttpDelete]
public HttpResponseMessage DeleteFolder(int id)
{
// Do stuff
}
在我的客户端应用程序中,我有一个允许多次删除的UI - 现在它只是为每个选定的id调用此端点,这不是超级高效的。在这种情况下,我希望能够向Delete方法发送一系列ID ...如何实现?
答案 0 :(得分:4)
[HttpDelete]
public HttpResponseMessage Folder([FromUri] int[] ids)
{
//logic
}
api call
DELETE /api/Folder?ids=1&ids=2
答案 1 :(得分:4)
[HttpDelete]
public HttpResponseMessage DeleteFolder(int[] ids)
{
// Do stuff
}
然后您可以发送以下HTTP请求:
DELETE /api/somecontroller HTTP/1.1
Accept: application/json
Content-Length: 7
Content-Type: application/json
Host: localhost:52996
Connection: close
[1,2,3]