【发布时间】:2019-01-08 13:09:21
【问题描述】:
编辑:已解决,错字。 Smart me \ + " " 确实有效(反斜杠和空格有效)
我知道之前有人问过这个问题,我想引用 this 帖子,其中 - 对我来说正确的回答 - 使用反斜杠。
不幸的是,我不知道怎么做。我尝试了多行 curl 请求,以下两个示例让我在这里发帖,因为它们都不起作用:
采取 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 ' '
所以我想,在使用反斜杠之前添加空格可以解决这个问题。 但后来发生了这样的事情:
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"}%
所以现在它不接受 \ 作为换行符终端语法,但会尝试拦截它。
我错过了什么?
【问题讨论】: