No matter how I format the raw portion of this request, I cannot avoid the parsing error below.
I have a Rails API with a create method that passes the spec, to illustrate that the controller message is sound:
describe "POST power_up" do
let!(:client) { FactoryGirl.create :client, name: "joe", auth_token: "asdfasdfasdfasdfasdfasdf" }
it "should create and save a new Power Up" do
expect { post :create, format: :json, power_up: FactoryGirl.attributes_for(:power_up) }.to change(V1::PowerUp, :count).by(1)
end
end
I'm using Postman to try to POST to it. No matter what I try I'm getting the error:
Started POST "/v1/power_ups.json" for 127.0.0.1 at 2014-08-30 18:05:29 -0400
Error occurred while parsing request parameters.
Contents:
{
'name': 'foo',
'description': 'bar'
}
ActionDispatch::ParamsParser::ParseError (795: unexpected token at '{
'name': 'foo',
'description': 'bar'
}
Postman request setup:
I've also tried:
{
'power_up': {
'name': 'foo',
'description': 'bar'
}
}
Code from create method and strong parameters declaration in power_ups_controller.rb
:
def create
@power_up = PowerUp.new(power_up_params)
if @power_up.save!
redirect_to @power_up
end
end
private
def power_up_params
params.require(:power_up).permit(:name, :description)
end