【发布时间】:2018-10-11 13:24:06
【问题描述】:
我正在学习构建一个 RESTful API,我正在命令行上使用 curl。
curl -i -H "Content-Type:application/json" -X POST \
-d "{"""title""":"""Read a book"""}" \
http://localhost:5000/todo/api/v1.0/tasks
它向我显示了这个错误:
curl: (6) Could not resolve host: a
curl: (3) [globbing] unmatched close brace/bracket in column 6
HTTP/1.0 400 BAD REQUEST
Content-Type: text/html
Content-Length: 204
Server: Werkzeug/0.14.1 Python/3.7.0
Date: Thu, 11 Oct 2018 13:20:28 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>Failed to decode JSON object: Unterminated string starting at: line 1 column 10 (char 9)</p>
【问题讨论】:
-
JSON 中的引号可能有问题。看看这里的例子,也许它会做的伎俩stackoverflow.com/questions/7172784/…
-
你能用
-v标志再次运行相同的命令并发布输出吗?