views:

471

answers:

1

How do I send a JSON request in ruby? I have a JSON object but I dont think I can just do .send. Do I have to have javascript send the form?

Or can I use the net/http class in ruby?

With header - content type = json and body the json object?

Thanks

A: 

Using net/http is pretty easy - see this page for a pretty clear example of how to do a POST request with net/http and JSON.

Read the net/http docs and look at the Curb gem (although you won't be able to use Curb if you use JRuby or IronRuby). Also, look at Rest-Client.

Tom Morris