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

Rodrigo Castro
Rodrigo Castro
15,652 Points

Problem running cURL command

I have exactly the same code as in the tutorial, but when running the following command:

curl -i -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"title":"Title goes here"}' http://localhost:3000/api/todo_lists

It returns a bunch of errors, and I get the following error on the server:

Started POST "/api/todo_lists.json" for 127.0.0.1 at 2016-08-03 15:22:19 +0100 Error occurred while parsing request parameters. Contents:

'{title:Title goes here}'

ActionDispatch::ParamsParser::ParseError (795: unexpected token at ''{title:Title goes here}''):

Does anybody knows the solution?

Thanks in advance. Rodrigo.

Rodrigo Castro
Rodrigo Castro
15,652 Points

I finally found the solution and I am posting here just in case anybody else is having the same problem. Apparently the problem was that I am using Windows cmd which does not parse single quotes when using cURL. I solved the problem by substituting the single quotes by double quotes in the data and using forward slashes before the double quotes inside the brackets. -d "{\"title\": \"Title goes here\"}"

So the final command was:

curl -i -H "Accept: application/json" -H "Content-type: application/json" -X POST -d "{\"title\": \"Title goes here\"}" http://localhost:3000/api/todo_lists