我正在学习Apigility(Apigility docu-> REST Service Tutorial),并尝试通过cURL发送具有基本身份验证的POST请求:
$ curl -X POST -i -H "Content-Type: application/hal+json" -H "Authorization: Basic YXBpdXNlcjphcGlwd2Q=" http://apigilityhw.sandbox.loc/status
YXBpdXNlcjphcGlwd2Q=
是带有我的凭据的基数为64的编码字符串apiuser:apipwd
。凭据保存在/data/htpasswd
(apiuser:$apr1$3J4cyqEw$WKga3rQMkxvnevMuBaekg/
)中。
看起来像这样:
HTTP/1.1 401 Unauthorized
Server: nginx/1.4.7
Date: Mon, 22 Sep 2014 07:48:47 GMT
Content-Type: application/problem+json
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.5.12-1~dotdeb.1
WWW-Authenticate: Basic realm="api"
这里的错误在哪里?如何运作?