I am trying to make a basic session api using a tutorial (https://medium.com/@diamondgfx/building-a-reading-queue-in-ember-and-phoenix-part-1-getting-started-with-phoenix-521a19814ae5) but am running into a little conceptual trouble. My SessionController
has a create function that takes an argument like:
def create(conn, %{"user" => user_params}) do
I thought I would be clever and test this on a valid user using curl
like so:
curl -X POST http://localhost:4000/api/v1/sessions -d '{"email":"test@test.com","password":"s3cr3tp4ss"}'
but I get a non-matching error:
** (Phoenix.ActionClauseError) bad request to Picki.SessionApiController.create, no matching action clause to process request
where the relevant information seems to be:
Parameters: %{"{\"email\":\"test@test.com\",\"password\":\"s3cr3tp4ss\"}" => "[FILTERED]"}
So I used pry
to take a peak and it also shows that the input looks like
%{"{\"email\":\"test@test.com\",\"password\":\"s3cr3tp4ss\"}" => nil}
I tried a bunch of different ways of structuring the curl
input data, but none of them fared any better. So my question is, what is the right way to test this function? Is there a way to structure the input data from curl
so that it matches? Thanks!