首页 > 解决方案 > 多线终端输入

问题描述

编辑:已解决,错字。Smart me \ + " " 确实有效(反斜杠和空格有效)

我知道以前有人问过这个问题,我想参考这篇文章,其中 - 对我来说正确的回答 - 正在使用反斜杠。

不幸的是,我不知道如何。我尝试了多行 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"}% 

所以现在它不接受 \ 作为换行符终端语法,而是尝试对其进行拦截。
我错过了什么?

标签: bashshellterminalzsh

解决方案


你有一个错字。尝试:

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

错误消息会准确地告诉您问题所在。


推荐阅读