我有一个请求 API 的 iPhone 应用程序,它使用嵌套的参数结构来传递用户名和密码以进行登录。
在我的 Rails Controller 中,我通常使用以下方法成功检索此信息:
username = param[:session][:username]
我想使用 cURL 从 shell 测试我的 API。但我不知道如何提供嵌套参数?下面的代码不起作用......我尝试了多种变体。但似乎无法弄清楚?
curl -d '{"session":{"username":"test","password":"password"}}' http://testurl/remote/v1/sessions
任何帮助,非常感谢!
最佳答案
不同的框架可能会以不同的方式解释 http 查询参数,但对于 Rails,您应该能够摆脱以下情况:
curl -d 'session[username]=name&session[password]=pwd' http://testurl/remote/v1/sessions
关于curl - 使用 cURL 嵌套参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3860654/