elasticsearch初始时没有密码,在设置密码后,再使用postman发送请求时会报错,提示信息为认证失败,此时需要在发送时设置请求头部的认证。
报错信息:
{
"error": {
"root_cause": [
{
"type": "security_exception",
"reason": "unable to authenticate user [elastic] for REST request [/test_01]",
"header": {
"WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
}
}
],
"type": "security_exception",
"reason": "unable to authenticate user [elastic] for REST request [/test_01]",
"header": {
"WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
}
},
"status": 401
}
如图所示:
在请求时设置Authorization中填写你的用户名及密码即可。