相关疑难解决方法(0)

在Heroku环境中将POST请求视为GET

我有奇怪的情况.我有一个RoR应用程序,它提供了我从Java应用程序连接的REST API.

我正在本地开发RoR,并在Heroku环境中部署它.

无论如何(我尝试从Java APP,Mozilla REST客户端等)我尝试发送应该由api控制器中的create action处理的POST HTTP请求.在localhost上 - 一切都按预期工作.在Heroku生产环境中 - POST请求被视为正常的GET.

以下是此资源的路线:

        api_v1_items GET    /api/v1/items(.:format)                            api/v1/items#index {:format=>:json}
                     POST   /api/v1/items(.:format)                            api/v1/items#create {:format=>:json}
         api_v1_item GET    /api/v1/items/:id(.:format)                        api/v1/items#show {:format=>:json}
                     PATCH  /api/v1/items/:id(.:format)                        api/v1/items#update {:format=>:json}
                     PUT    /api/v1/items/:id(.:format)                        api/v1/items#update {:format=>:json}
                     DELETE /api/v1/items/:id(.:format)                        api/v1/items#destroy {:format=>:json}
Run Code Online (Sandbox Code Playgroud)

所以我正在尝试POST请求/api/v1/items传递所有必要的参数.

在localhost中,响应是正确的:

Started POST "/api/v1/items?token=l4XOHrhDApPqTp1u4TxBjQ" for 127.0.0.1 at 2014-05-15 22:11:49 +0200
Processing by Api::V1::ItemsController#create as JSON
Parameters: {"height"=>10.0, "item_name"=>"Super item", "width"=>20.0, etc...
Run Code Online (Sandbox Code Playgroud)

然而,同样的请求在Heroku被解雇为GET:

2014-05-15T20:27:58.137541+00:00 app[web.1]: Started GET "/api/v1/items?token=iEdDkDLiDUlWi0mDbr6XYw" for 89.74.57.51 at 2014-05-15 20:27:58 +0000
2014-05-15T20:27:58.223620+00:00 app[web.1]: Processing by Api::V1::ItemsController#index …
Run Code Online (Sandbox Code Playgroud)

post get ruby-on-rails http heroku

6
推荐指数
2
解决办法
1902
查看次数

标签 统计

get ×1

heroku ×1

http ×1

post ×1

ruby-on-rails ×1