【发布时间】:2021-03-22 23:37:22
【问题描述】:
大家好,所以我最近做了这个命令:
curl -X POST -H \"Content-Type: application/json\" -d '{\"password\": \"123\", \"email\": \"test@email.com\"}' http://localhost:3000/auth/create-token
我尝试不使用反斜杠,但它也不起作用。
错误信息:curl: (6) Could not resolve host: application curl: (6) Could not resolve host: "123", curl: (6) Could not resolve host: "email" curl: (3) [globbing] unmatched close brace/bracket in column 17
【问题讨论】:
-
所有的双引号都应该被转义吗?
\"Content-Type: application/json\"是两个单独的 shell 参数,没有正确引用。例如。'{\"password\": \"123\", \"email\": \"test@email.com\"}'被正确引用,因此它算作一个参数。 -
即使我这样做
curl -X POST -H "Content-Type: application/json" -d '{\"password\": \"123\", \"email\": \"toto@email.com\"}' http://localhost:3000/auth/create-token我仍然遇到同样的问题。 :// -
你没有删除所有的反斜杠......只需尝试
curl -X POST -H "Content-Type: application/json" -d '{"password": "123", "email": "toto@email.com"}' http://localhost:3000/auth/create-token。如果这不起作用,那么你的问题有一些你没有透露的背景。
标签: javascript curl