Using the Apache HttpClient on android, how do I send data to a RESTfull Ruby on Rails app using HttpPost.
This is my Controller:
# POST /products
def create
@product = Product.new(params[:product])
respond_to do |format|
if @product.save
flash[:notice] = 'Product was successfully created.'
format.html { redirect_to(@product) }
format.xml { render :xml => @product, :status => :created, :location => @product }
else
format.html { render :action => "new" }
format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
end
end
end
And this is my Java Code. Should I be passing the data in the URL name, or do I have to set it somewhere else? (httpost.setEntity perhaps?) Eventually I will be using JSON but for now I just want to get it so I can actually call the "create" method in Rails. Rails is getting the POST but never executes any code in the "create" method
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.0.100:3000/products/new");
HttpResponse response = httpclient.execute(httppost);
I am quite stuck and would appreciate if someone could point me in the right direction.