-2

EDIT: Solved, typo. Smart me \ + " " does work (backslash and space do work)

I know this has been asked before and I want to reference this post, where the - to me correct response - is using backslash.

Unfortunately, I do not know how. I tried a multiline curl request, and the following two examples made me post here, coz none of them worked:

Take 1:

curl -X PUT localhost:8080/employees/4\ 
-H 'Content-type:application/json'\
-d '{"name:" "Smurf", "role": "Blueman"}'
{"timestamp":"2019-01-08T13:06:36.563+0000","status":400,"error":"Bad Request","message":"Required request body is missing: payroll.Employee payroll.EmployeeController.replaceEmployee(payroll.Employee,java.lang.Long)","path":"/employees/4-H"}curl: (3) Port number ended with 'a'

[1/2]: "name:" "Smurf" --> <stdout>
--_curl_--"name:" "Smurf"
curl: (3) Port number ended with '"'

[2/2]:  "role": "Blueman" --> <stdout>
--_curl_-- "role": "Blueman"
curl: (3) Port number ended with ' '

So I figured, adding space before using the backslash would solve this. But then this happened:

curl -X PUT localhost:8080/employees/4 \
-H 'Content-type:application/json' \
-d '{"name:" "Smurf", "role": "Blueman"}'
{"timestamp":"2019-01-08T13:07:32.204+0000","status":400,"error":"Bad Request","message":"JSON parse error: Unexpected character ('\"' (code 34)): was expecting a colon to separate field name and value; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('\"' (code 34)): was expecting a colon to separate field name and value\n at [Source: (PushbackInputStream); line: 1, column: 11]","path":"/employees/4"}% 

so now it doesn't accept \ as the newline terminal syntax, but tries to interept it.
What am I missing?

InDaPond
  • 574
  • 3
  • 6
  • 23

1 Answers1

2

You have a typo. Try with:

curl -X PUT localhost:8080/employees/4 \
-H 'Content-type:application/json' \
-d '{"name": "Smurf", "role": "Blueman"}'

The error message tells you exactly which is the problem.

Poshi
  • 5,332
  • 3
  • 15
  • 32
  • yes, thank you I just stumbled upon that one, too. I'll leave this here if anyone else manages to pull off this one. – InDaPond Jan 08 '19 at 13:15