Closed willemodendaal closed 2 months ago
Perhaps there's something wrong with my "base" route? Or with my "api/json" route and how that forwards to "/flashcards"? I'm not sure how to configure these exactly.
This bit in the error also seemed strange: "jsonapi":{"version":"1.0"}
, since I'm using ash_json_api v1.1.
I tried a mix deps.compile mime --force
, but that didn't make a difference.
Here's what the iex -S mix
output looks like, when the curl
happens:
[info] GET /api/json/flashcards
[debug] Processing with MyApi2Web.JsonApiRouter
Parameters: %{}
Pipelines: [:api]
[info] Sent 404 in 182µs
I added some debug statements in my local ash_json_api dependency, and can confirm that the code gets here, if that helps: https://github.com/ash-project/ash_json_api/blob/main/lib/ash_json_api/controllers/router.ex#L63
I figured it out! Because my router's forward
configuration was set to "/flashcards", and my resource's base
was set to "/flashcards", the actual path to the resource ended up being: "/api/json/flashcards/flashcards"
Very obvious in hindsight. I created a PR to clarify in the documentation: https://github.com/ash-project/ash_json_api/pull/155
Describe the bug I have a minimal set-up, following the documentation. I have a simple resource, that I would like to "GET" through the json api, but I get a 404 error, even though everything seems ok from my side.
To Reproduce Create a domain:
Create a resource:
Add JsonApiRouter:
Add json_api configuration in router.ex, with "forward":
Configure as per the documentation in config.ex:
List routes in
iex -S mix
:^ looks good to me.
Try calling the "get" with
curl localhost:4000/api/json/flashcards
and see response:Is there something obvious I'm doing wrong? When I interact with my resource via iex, it all works fine. So I think my Ash configuration is ok, and that there's something wrong with how I'm setting up the JsonApi bits.
Expected behavior When I call
curl localhost:4000/api/json/flashcards
, I expect a list of the 'flashcards' I've created already.** Runtime