A common practice while building REST api's is
to send the params as plain http attributes. For a
post request they can be encoded within the
message body (application/x-www-form-urlencoded).
This is best explained by the following curl
What you've done, however is this:
The correct request for json payload woul be:
curl --header "CONTENT_TYPE:
Personally i prefer the first option, however
this is up to the api designer.
In order to convert json payload into a params
hash in rails, you can set the Content-Type"
header of your request to "application/json"
In order to use the first option within a rspec
controller test you do:
post :create, user: user.attributes
For the second option, perform:
post :create, user.to_json,
"CONTENT_TYPE" => 'application/json'