使用CURL或POSTMAN客户端时,找不到我的以下API路由
Started POST "/api/users/register_handheld" for 181.74.100.34 at 2017-05-11 11:27:42 +0000
DEBUG: Chewy strategies stack: [2] <- atomic @ /home/deploy/boold/shared/bundle/ruby/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17
ActionController::RoutingError (No route matches [POST] "/api/users/register_handheld"):但是当我运行rake routes时,这个网址就出现了。
api_users_register_handheld POST /api/users/register_handheld(.:format)
crowd/api/v1/handheld_users#create {:format=>"json"}如果我在rails控制台中点击,这个URL实际上是有效的:
app.post "/api/users/register_handheld"
Started POST "/api/users/register_handheld" for 127.0.0.1 at 2017-05-11 11:21:03 +0000
DEBUG: Chewy strategies stack: [3] <- atomic @ /home/deploy/boold/shared/bundle/ruby/2.2.0/gems/chewy-0.8.4/lib/chewy/railtie.rb:17
Processing by Crowd::Api::V1::HandheldUsersController#create as JSON路由文件是
namespace :api, defaults: {format: 'json'} do
scope module: :v1 do
resources :dashboard, controller: "account/dashboard"
post '/account/settings/create_notification' => 'account/settings#create_notification'
post '/users/register' => 'users#create'
post 'users/register_handheld' => 'handheld_users#create'
put 'users/update_profile' => 'handheld_users#update_profile'
post 'users/login' => 'handheld_users#login'注意:此存储库是Rails引擎
发布于 2017-05-11 19:59:43
试试下面的代码:
/api/users/register_handheld.json按照您指定的格式类型json
发布于 2020-12-14 22:25:23
也许这对某些人有帮助。
使用POSTMAN时,我意外地取消选中了报头中的Host密钥(每次发送任何请求时,POSTMAN都会自动生成它)。这是一场噩梦,直到我将我的请求与类似的请求进行比较,找到了丢失的密钥,才找到问题所在。
https://stackoverflow.com/questions/43914485
复制相似问题