cURL post to server resulting in a UnknownFormat error
I am very new at rails and having a hard time doing a cURL post to my
server. Any help would be apreciated.
I am posting JSON data to my server. this is my curl post curl -X POST -H
"Content-Type: application/json" -d '[{"photo":[{ "location": "location",
"userID": "userid" },{ "location": "location", "userID": "userid"
},{"location": "location", "userID": "userid"}]}]'
http://localhost:3000/photo/create
this is my controller:
class SendphotoController < ApplicationController
def create
@photo = Photo.new(:photo => params[:location], :photo =>
params[:userID])
respond_to do |format|
if @photo.save
puts "Done"
else
puts "NOPE"
end
end
end
I get the error of ActionController::UnknownFormat
(ActionController::UnknownFormat):
This is the full log:
Started POST "/photo/create" for 127.0.0.1 at 2013-09-08 22:03:56 -0400
Processing by SendphotoController#create as */*
Parameters: {"_json"=>[{"photo"=>[{"location"=>"location",
"userID"=>"userid"}, {"location"=>"location", "userID"=>"userid"},
{"location"=>"location", "userID"=>"userid"}]}],
"sendphoto"=>{"_json"=>[{"photo"=>[{"location"=>"location",
"userID"=>"userid"}, {"location"=>"location", "userID"=>"userid"},
{"location"=>"location", "userID"=>"userid"}]}]}}
WARNING: Can't mass-assign protected attributes for Photo: photo
app/controllers/sendphoto_controller.rb:4:in `create'
(0.0ms) begin transaction
SQL (0.3ms) INSERT INTO "photos" ("created_at", "updated_at") VALUES
(?, ?) [["created_at", Mon, 09 Sep 2013 02:03:56 UTC +00:00],
["updated_at", Mon, 09 Sep 2013 02:03:56 UTC +00:00]]
(215.8ms) commit transaction
Done
Completed 406 Not Acceptable in 235ms
ActionController::UnknownFormat (ActionController::UnknownFormat):
app/controllers/sendphoto_controller.rb:5:in `create'
No comments:
Post a Comment