market_place_api
market_place_api copied to clipboard
3.2.1 Routing error
I"m getting a ActionController::RoutingError (No route matches [GET] "/users/1.json")
I have tried curl -H 'Accept: application/api.bluemage.systems.v1' 'http://10.0.0.11:3000/users/1.json'
curl -H 'Accept: application/api.bluemage.systems.v1' 'http://10.0.0.11:3000/users/1'
curl -H 'Accept: application/api.bluemage.systems.v1' http://10.0.0.11:3000/users/1
and none of them work, the route shows up with rake routes.
Mind showing us what your routes file looks like, as well as the output from rake routes?
Is the devise_for :users line before the api namespace?
It's not working for me either, here is my command: "curl -H 'Accept: application/application/vnd.marketplace.v1' http://api.market_place_api.dev/users/1" . I have devise_for :users before the api namespace
Here is my routes.rb:
MarketPlaceApi::Application.routes.draw do
devise_for :users
namespace :api, defaults: { format: :json}, constraints: { subdomain: 'api' }, path: '/' do
scope module: :v1, constraints: ApiConstraints.new(version: 1, default: true) do
# list resources
resources :users, :only => [:show]
end
end
end
Any errors being produced? Do you see the connection being attempted from your rails console?
@OxenBoxen is there any update on this? were you able to solved it?
I have the same problem too..
curl: (7) Failed to connect to api.market_place_api.dev port 80: Connection refused
this is my route file
MarketPlaceApi::Application.routes.draw do
# Api definition
namespace :api, defaults: { format: :json }, constraints: { subdomain: 'api' }, path: '/' do
scope module: :v1, constraints: ApiConstraints.new(version: 1, default: true) do
resources :users, :only => [:show]
end
end
devise_for :users
end
this is my curl command
curl -H 'Accept: application/application/vnd.marketplace.v1' http://api.market_place_api.dev/users/1
also, my main question.. can we do this without actually starting a server at http://api.market_place_api.dev?
thanks
I was able to make this work based on the following answer from Phanindra
To use localhost:3000/api/v1/users/1 change routes.rb to this
namespace :api, defaults: { format: :json } do
namespace :v1 do
devise_for :users
resources :users, :only => [:show]
end
end
later I try to use the namespaces as in the guide, but right now it is not my priority
I do the following curl command and I receive the json response,
curl 'http://0.0.0.0:3000/api/v1/users/1'
{"id":1,"email":"[email protected]","created_at":"2017-10-26T13:54:18.343Z","updated_at":"2017-10-26T13:54:18.343Z"}
I have a server running on localhost:3000