Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Zachary Betz
Zachary Betz
10,413 Points

Use these small tweaks to make the curl command work in Windows

The original curl command, which presumably works on Mac and Linux, is below.

curl \
-H "Accept: application/json" \
-H "Content-type: application/json" \
-X POST \
-d '{"title":"The Title will go here"}' \
http://localhost:3000/api/todo_lists.json

However, if you are like me, and are following along on a Windows machine, this won't work for you. To make it work, I had to replace the multi-line characters (replace \ with ^), replace the single quotes around the JSON with double quotes, then escape all double quotes within the JSON (replace " with \"). Here's the updated command.

curl ^
-H "Accept: application/json" ^
-H "Content-type: application/json" ^
-X POST ^
-d "{\"title\":\"The Title will go here\"}" ^
http://localhost:3000/api/todo_lists.json

1 Answer

Thanks for this!