在 GET 中传递数组以进行 REST 调用 [英] Passing array in GET for a REST call

查看:43
本文介绍了在 GET 中传递数组以进行 REST 调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网址可以为这样的用户获取约会:

I have a url to fetch appointments for a user like this:

/user/:userId/appointments

如果我想为多个用户预约,url 应该是什么样子的?

How should the url look like if I want to get appointments for multiple users?

应该是:

/appointments?users=1d1,1d2..

谢谢,克里斯.

推荐答案

集合是一种资源,所以/appointments 作为资源很好.

Collections are a resource so /appointments is fine as the resource.

集合通常还通过查询字符串提供过滤器,这本质上就是 users=id1,id2... .

Collections also typically offer filters via the querystring which is essentially what users=id1,id2... is.

所以,

/appointments?users=id1,id2 

作为过滤的 RESTful 资源很好.

is fine as a filtered RESTful resource.

这篇关于在 GET 中传递数组以进行 REST 调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆