在Windows命令提示符(cmd)中使用curl
将json格式的数据发布到服务器后,我现在正在测试响应数据,并收到“错误请求”消息。
我也检查了请求格式。
cmd:
curl -i -X POST -H "Content-Type: application/json" -d '{ "isbn":"123442123, 97885654453443","title":"Learn how to build modern web application with MEAN stack","author": "Didin J.","description":"The comprehensive step by step tutorial on how to build MEAN (MongoDB, Express.js, Angular 5 and Node.js) stack web application from scratch","published_year":"2017","publisher":"Djamware.com" }' localhost:3000/api
然后
HTTP/1.1 400 Bad Request
X-Powered-By: Express
Content-Type: text/plain; charset=utf-8
Content-Length: 11
ETag: W/"b-EFiDB1U+dmqzx9Mo2UjcZ1SJPO8"
Date: Wed, 05 Sep 2018 01:41:55 GMT
Connection: keep-alive
Bad Request
怎么了?请帮助我。
答案 0 :(得分:1)
您将标题写为“ curl issue ...”,但我认为curl从来没有任何问题,因为它被广泛使用。
您的请求数据没有问题。
根据我的经验,数据库连接中会存在问题。
请检查并检查MongoDB连接的准确性。