Closed rajaravivarma-r closed 7 years ago
Good idea, will do.
was already considering adding --json
flag as alias of `-H 'Content-type: application/json'``
Not that you can place -H 'Content-type: application/json'
in your config file so you don't have to precise it over and other.
+1 for --json
@akhyrul haha, comming soon. :) I restarted to hack around. Trying to reset up the test infrastructure before to go forward: cf https://github.com/AdrieanKhisbe/resty/tree/test-with-cucumber
I intended to do it, once I complete the major release. sorry for the delay
Done in c4c739e, will land with the very soon 3.0 release.
A --json
with set both Accept and Content-Type to json
closing the issue.
As per the following example, given in the README
POST /blogs.json '{"title" : "new post", "body" : "This is the new new."}'
it should work without setting Content-type Header. But it doesn't.Example: When the POST request is as follows
POST /creator/files.json '{ "attributes": [ {"title": "New Book" } ] }'
This is how Rails receives the parameterParameters: {"{ \"attributes\": "=>{" {\"title\": \"New Book\" } "=>{" }"=>nil}}}
The scenario remains the same when the input is read from a file or pipeecho '{ "attributes": [ {"title": "New Book" } ] }' | POST /creator/files.json
But when the POST request is made with Content-type as follows
POST /creator/files.json '{ "attributes": [ {"title": "New Book" } ] }' -H 'Content-type: application/json'
Rails receives the parameters properly as,{"attributes"=>[{"title"=>"New Book"}]}
Please add
Content-type: application/json
Header automatically if the URL ends with .json. Though I am not sure if this is applicable only for Rails.