-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
I am having trouble sending data through HTTP REST. When I try and POST json data through the chrome extension 'Simple REST Client' I get a 500 internal server error stating "The document does not have a valid root". When I curl I get a 406 error. But when I leave the data filed empty in both the client and curl a blank document is created! I have changed the json text to every possible valid combination and putting the data back in that the GET produces but no luck!
My controller code is:
def create @verify= Verify.new(params[:verify]) respond_to do |format| if @verify.save format.html { redirect_to( :back, :notice => 'Verified') } format.json { render :json => @verify, :status => :created, :location => @verify} else format.html { render :action => "new" } format.xml { render :xml => @verify.errors, :status => :unprocessable_entity } format.json { render :json => @verify.errors, :status => :unprocessable_entity } end end end
Sample json
http://localhost:3000/verifies.json
{"www" : "wwww"}I'm using Mongoid and Devise gems (tried removing before_filter from controller but that made no difference).
Tried adding include_root_in_json: true to mongoid.yml but that had no effect.
Any ideas?