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中填写你的用户名及密码即可。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐