[英]When should one use json body in a POST request in REST service?
When should one use JSON body in a POST in REST service? 什么时候应该在REST服务的POST中使用JSON主体?
How many parameters / arguments would one start considering json body? 一个人会开始考虑json主体多少个参数/参数?
I have a case here where I would like to POST a request to a server with a list of subscription toggled explicityly. 我在这里有一种情况,我想向服务器发出请求,并明确切换订阅列表。
The following is what I came up with a POST request body. 以下是我提出的POST请求正文。 But should I also consider using url arguments for factory_id?
但是我还应该考虑将url参数用于factory_id吗?
{
"data": [
{
"is_subscribed": false,
"game_id": 0
},
{
"game_id": 1,
"is_subscribed": true
}
],
"factory_id": 3
}
Thanks! 谢谢!
I think it depends on the agreement between server and client side on the protocol used to exchange data, it can be JSON, XML and others. 我认为这取决于服务器和客户端之间用于交换数据的协议的协议,可以是JSON,XML等。 I don't think it's a good idea to exchange data using
URL
, since you can't transfer binary data in this way and it introduces overhead to server for parsing and assembling the message. 我认为使用
URL
交换数据不是一个好主意,因为您不能以这种方式传输二进制数据,并且这会给服务器解析和组合消息带来开销。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.