0

I am trying to post to neo4j using curl on a mac and need a little help.

curl -i -H accept:application/json -H content-type:application/json
-XPOST http://localhost:7474/db/data/transaction/commit -d '{"statements":[{"statement":"CREATE (m:Movie {title: 'Harry Potter', year : '2001-11-14’}) RETURN m”}]}’

Error: -bash: syntax error near unexpected token `)'

If it is an escape character issue, where do I need to put them?

Any help is greatly appreciated. Thank you!

codeforester
  • 39,467
  • 16
  • 112
  • 140
StephM
  • 21
  • 2
  • 1
    You can't have single quotes within a single-quoted string. Not only do you have to fix that, but you're using no less than four different types of quotes. – Biffen Feb 08 '17 at 05:55

1 Answers1

1

You have some quoting issues. Here is the corrected version:

curl -i -H accept:application/json -H content-type:application/json \
  -XPOST http://localhost:7474/db/data/transaction/commit \
  -d $'{"statements":[{"statement":"CREATE (m:Movie {title: \'Harry Potter\', year : \'2001-11-14\'}) RETURN m"}]}'

As pointed out by @Biffen, you can't have single quotes inside single quotes. And hence, I have used shell quoting $'' method to protect the quotes.


See also:

A three-point formula for quotes

Community
  • 1
  • 1
codeforester
  • 39,467
  • 16
  • 112
  • 140
  • thanks for your response but still getting the same error! curl -i -H accept:application/json -H content-type:application/json \ -XPOST http://localhost:7474/db/data/transaction/commit \ -d \$'{"statements":[{"statement":"CREATE (m:Movie {title: \'Harry Potter\', year : \'2001-11-14\'}) RETURN m"}]}' -bash: syntax error near unexpected token `)' – StephM Feb 08 '17 at 06:11
  • There was a small typo in my answer - a \ before the `$` after `-d`. Please see the updated one. – codeforester Feb 08 '17 at 06:12
  • 1
    Thank you! This worked for me :) curl -i -H accept:application/json -H content-type:application/json -XPOST http://localhost:7474/db/data/transaction/commit -d $'{"statements":[{"statement":"CREATE (m:Movie {title: \'Harry Potter\', year : \'2001-11-14\'}) RETURN m"}]}' – StephM Feb 08 '17 at 06:17
  • There is quite a bit of confusion around the usage of quotes. That's why I just made that post ("See also"). Will greatly appreciate your feedback. Thanks. – codeforester Feb 08 '17 at 06:19