问题描述
我已经设置了 API 平台,并且正在尝试使用 curl 测试 API,例如。
curl -X POST -H "Content-Type: application/json" http://localhost/authentication_token -d '{"email":"test@test.com","password":"the_new_password"}'
curl http://localhost/docs
我没有得到服务器的响应,总是空白。
解决方法
请求必须是 HTTPS,因为 HTTP 请求似乎被简单地丢弃/忽略了。添加 -k
标志,因为证书将是自签名的,并且 CURL 会出错。
curl -X POST -H "Content-Type: application/json" https://localhost/authentication_token -d '{"email":"test@test.com","password":"the_new_password"}' -k
curl https://localhost/docs -k