gpt4 book ai didi

ruby-on-rails - 如何使用 curl 查询 restful rails 应用程序?

转载 作者:数据小太阳 更新时间:2023-10-29 02:23:12 24 4
gpt4 key购买 nike

这是我的问题..资源:用户方法:创建

我这样调用curl:

curl -X POST -H 'Content-type: text/xml' -d '<xml><login>john</login><password>123456</password></xml>' http://0.0.0.0:3000/users

但是 rails 中的参数散列看起来像这样:

{"xml"=> {"login"=>"luca", "password"=>"123456"}}

我希望它看起来像这样:

{"login"=>"luca", "password"=>"123456"}

如果我在 url 上传递参数 (...?login=luca&pas...),我可以让它变成那样,但这并不好...

有什么想法吗?

最佳答案

curl -X POST -d 'login=john&password=123456' http://0.0.0.0:3000/users

另见:Stack Overflow: How do I make a POST request with curl

关于ruby-on-rails - 如何使用 curl 查询 restful rails 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1219338/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com