API在查询字符串中需要POST参数吗? [英] API requires POST arguments in a query string?

查看:127
本文介绍了API在查询字符串中需要POST参数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Twitter API并注意到一些有趣的东西 - 对于更新,它们需要POST方法,但期望查询字符串中的参数。 (例如,参见其开发者控制台中的状态/更新调用此处。)

I'm playing with the Twitter API and noticed something funny- For updates, they require POST methods but expect the arguments in the query string. (See for example, the status/update call in their developer console here.)

显然这在技术上是可行的,但为什么有人这样做呢? POST参数是否属于正文?

Obviously this is technically possible, but why would anyone do it like that? Don't POST arguments belong in the body?

推荐答案

任一选项都同样有效。我最喜欢在POST的URL中使用参数的示例是在地图上设置航点的应用程序。例如

Either option is just as valid. My favourite example for using parameters in the URL for a POST is an application that sets waypoints on a map. e.g.

     POST /map/route/45/waypoints?lat=35&long=74

在这种情况下,参数在URI中作为位置的标识符更有意义,而不仅仅是在正文中传递给通用资源的参数。

In this case, the parameters make more sense in the URI as identifiers of a location, than just parameters being passed in the body to generic resource.

这篇关于API在查询字符串中需要POST参数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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