【发布时间】:2017-11-03 06:54:21
【问题描述】:
有一个带有一些资源的 RESTful API。我需要 GET 一些带有参数的资源,这些参数在 JSON 表示中如下所示:
{
"id": int,
"params":
[
{
"param1": "string",
"param2": "string"
},
{
"param1": "string",
"param2": "string"
}
]
}
我有两种可能的方式在查询字符串中发送这个对象:
id=1&params[0].param1=test&params[0].param2=test&params[1].param1=test&params[1].param2=testid=10000&params[0][param1]=test&params[0][param2]=test&params[1][param1]=test&params[1][param2]=test
问题是params数组可以有很多项,查询字符串可能很长,超过2000个字符。
通过 GET 在请求正文中发送参数是个坏主意。
如何以适当的 RESTful 方式发送此类参数?我可以使用其他 HTTP 方法吗?或者只是更改服务器上的查询长度?
【问题讨论】:
标签: rest url get restful-architecture restful-url