Skip to content
Tom von Schwerdtner edited this page Aug 5, 2013 · 2 revisions

In short, you need to set the header and set raw_post to json.

resource "Order" do
  header "Content-Type", "application/json"
 
  post "/orders" do
    parameter :name, "Order name"
 
    let(:name) { "New order" }
 
    let(:raw_post) { params.to_json }
 
    example "Sending JSON" do
      do_request
 
      response_body.should be_json_eql({ :name => name }.to_json)
      status.should == 201
    end
  end
end
Clone this wiki locally