请求接口时,如果提示:

    1. {
    2. "auth": "Invalid credentials"
    3. }

    说明请求接口时的用户名和密码不正确,需要传递正确的用户名和密码 提示 Invalid credentials - 图1

    对应的 Python 示例

    1. import requests
    2. import json
    3. url = "localhost:4080/api/_analyze"
    4. payload = json.dumps({
    5. "analyzer": "standard",
    6. "text": "ZincSearch is a memory-save search engine for multi-purpose useage"
    7. })
    8. headers = {
    9. 'Content-Type': 'application/json',
    10. 'Authorization': 'Basic YWRtaW4xOnBhc3M0WmluYw=='
    11. }
    12. response = requests.request("POST", url, headers=headers, data=payload)
    13. print(response.text)