Bennington
Bennington

Reputation: 295

POST via json in Ruby on Rails

I'm trying to create record in db via json. The problem is that i don't know how to compose http request in URL bar:

It should be something like:

http://localhost:3000/addnewpost.json?content=sometexthere

Or this is not correct?

Upvotes: 0

Views: 206

Answers (1)

Jacob Mattison
Jacob Mattison

Reputation: 51052

It's not correct. Creating a record should be a POST command, not a GET. As such, the data content should go in the POST headers, not in the URL.

Are you sending this POST directly from Ruby? (if so, you'll want to look at Net::HTTP or some other ruby HTTP client). Show us some code and we'll help you improve it.

Upvotes: 1

Related Questions