build-apis-you-wont-hate icon indicating copy to clipboard operation
build-apis-you-wont-hate copied to clipboard

Behat payload results in 422 Unprocessable Entity

Open lowerends opened this issue 10 years ago • 1 comments

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 avatar Jul 10 '14 20:07 lowerends

@lowerends Have you tried editing to ->$method($resource, array('body' => $this->requestPayload)); ?

centerax avatar Dec 01 '14 15:12 centerax