How to use curl to make a http post on a form with nested attributes using application/x-www-form-urlencoded, instead of application/xml?
With XML it works just fine:
curl -i -X 'POST' -H 'Content-Type: application/xml' http://localhost:3000 -d '<user><name>John Doe</name><emails><email><address>[email protected]</address></email><email><address>[email protected]</address></email></emails></user>'
And the result:
Parameters: {"action"=>"profile", "controller"=>"users", "user"=>{"name"=>"John Doe", "emails"=>{"email"=>[{"address"=>"[email protected]"}, {"address"=>"[email protected]"}]}}}
But, I'm trying to accomplish the same result without xml.
I tried like this:
curl -i -X POST -d 'user[name]=John Doe&user[emails][email][address][email protected]&user[emails][email][address][email protected]' http://localhost:3000/
But it didn't worked:
Parameters: {"user"=>{"name"=>"John Doe", "emails"=>{"email"=>{"address"=>"[email protected]"}}}}
would you please try the following:
curl -i -X POST -d 'user[name]=John Doe&user[emails][][email][address][email protected]&user[emails][][email][address][email protected]' http://localhost:3000/
Note the []
behind [emails]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With