I am currently creating an API for an author-books type of app.
I already created the Library functions and the controllers and view for books but upon trying to submit a PUT data to http://localhost:3000/books I am encountering the following error response:
# Phoenix.Router.NoRouteError at PUT /books
Exception:
** (Phoenix.Router.NoRouteError) no route found for PUT /books (LibraryApiWeb.Router)
(library_api) lib/library_api_web/router.ex:1: LibraryApiWeb.Router.__match_route__/4
(library_api) lib/phoenix/router.ex:304: LibraryApiWeb.Router.call/2
(library_api) lib/library_api_web/endpoint.ex:1: LibraryApiWeb.Endpoint.plug_builder_call/2
(library_api) lib/plug/debugger.ex:122: LibraryApiWeb.Endpoint."call (overridable 3)"/2
(library_api) lib/library_api_web/endpoint.ex:1: LibraryApiWeb.Endpoint.call/2
(phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:33: Phoenix.Endpoint.Cowboy2Handler.init/2
(cowboy) d:/@@@/@gbzapp/library_api/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2
(cowboy) d:/@@@/@gbzapp/library_api/deps/cowboy/src/cowboy_stream_h.erl:296: :cowboy_stream_h.execute/3
(cowboy) d:/@@@/@gbzapp/library_api/deps/cowboy/src/cowboy_stream_h.erl:274: :cowboy_stream_h.request_process/3
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
I have the proper routes entry:
...
scope "/", LibraryApiWeb do
pipe_through :api
get "/", StatusController, :index
resources "/authors", AuthorController, except: [:new, :edit]
resources "/books", BookController, except: [:new, :edit]
end
end
Been trying to check what I could be missing but been on it for some hours already.
I am using phoenix 1.4.3.
Would be glad to hear your feedback. Thanks!