jdx / mean-sample

Sample project for Write Modern Web Apps with the MEAN Stack by Jeff Dickey
https://mean-sample.herokuapp.com
165 stars 90 forks source link

CURL command does not work on bash #6

Open FrankBowers24 opened 10 years ago

FrankBowers24 commented 10 years ago

Your example curl command from chapter 4 does not work with bash. I finally figured out that the exclamation point was confusing the shell.

$ curl -v -H "Content-Type: application/json" -XPOST --data "{\"username\":\"dickeyxxx\", \"body\":\"node rules!\"}" localhost:3000/api/posts -bash: !\"}": event not found

jdx commented 10 years ago

ahhh this is strange that we didn't run into this through the writing/editing process... but you're totally right, I get the error too

thanks for the suggestions, keep them coming!

Deborah-Digges commented 9 years ago

The problem is that you have an exclamation mark in the body \"body\":\"node rules!\". Bash interprets it as "substitute here the last command that began with the character(s) immediately following the exclamation mark", and grumbles at you that it cannot find an event (command) in your history that began with a single double-quote.

The solution is to escape the exclamation mark, like so: \"body\":\"node rules\!\"}"

rduran commented 6 years ago

Maybe using single quotes (') as external wrapper to the --data JSON part could do the trick. https://ec.haxx.se/cmdline-options.html