【问题标题】:Terminal Input over several lines [closed]多行终端输入[关闭]
【发布时间】: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"}% 

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

【问题讨论】:

    标签: bash shell terminal zsh


    【解决方案1】:

    你有一个错字。尝试:

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

    错误信息会告诉你究竟是哪一个问题。

    【讨论】:

    • 是的,谢谢,我也偶然发现了那个。如果其他人设法完成这个,我会把它留在这里。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-05
    • 2019-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-05
    • 2015-12-05
    相关资源
    最近更新 更多