build-apis-you-wont-hate
build-apis-you-wont-hate copied to clipboard
Behat payload results in 422 Unprocessable Entity
I bought Phil's book today and must say it's a good read.
I'm currently writing Behat tests for my API and want to try testing a post with a payload. I have a scenario like this:
Given I have the payload:
"""
{"name": "foo_name"}
"""
When I request "POST /api/users"
Then I get a "200" response
When running the test, it seems the payload is not sent. Debugging learns that Input::get('name')
in my store() function returns 422 Unprocessable Entity
.
Other test, without payload, are running fine. Posting the same payload in Chrome's RestClient does work correctly.
Any ideas on what's going on here?
Thanks
@lowerends Have you tried editing to ->$method($resource, array('body' => $this->requestPayload));
?