doris icon indicating copy to clipboard operation
doris copied to clipboard

_stream_load 发送json报 no valid Basic authorization 错误

Open taoxu1234 opened this issue 5 years ago • 4 comments

描述

  1. 我用postman 发送 _stream_load json请求时,报no valid Basic authorization
  2. 有时候是成功的,不是每次都报no valid Basic authorization,也会 success

步骤

  1. 我的版本是最新执行git clone https://github.com/apache/incubator-doris.git 的版本,具体版本号暂时不清楚在哪看,调用接口ip:port/api/bootstrap 显示的{"replayedJournalId":0,"queryPort":0,"rpcPort":0,"version":"","status":"OK","msg":"Success"} 中version为空。
  2. 我的环境是1个fe加上3个be
  3. 由于本地安装了docker,网卡比较多,我的ip通过配置文件写死了。
  4. 用postman 发送http请求 有时候是成功,有时候显示 no valid Basic authorization,看了下日志也没有明显的报错信息,
  5. 执行SHOW PROC '/frontends'; SHOW PROC '/backends'; 两个命令,机器状态也正常。

Expected behavior 全部都是成功 Screenshots suc au fe be1 be2 be3 tail

taoxu1234 avatar Apr 30 '21 10:04 taoxu1234

solved?

zjd-melo avatar Jun 07 '21 12:06 zjd-melo

curl --location-trusted -u root -T _data.csv -H "label:20" -H "format:csv_with_names" -H "Expect:100-continue" -H "column_separator:," http://192.168.88.13:8030/api/test_db/test_streamload/_stream_load

This curl works in cmd, postman and go app but not works in C#, node, python. The error: [NOT_AUTHORIZED]no valid Basic authorization

sjahongir avatar Nov 19 '24 02:11 sjahongir

curl --location-trusted -u root -T _data.csv -H "label:20" -H "format:csv_with_names" -H "Expect:100-continue" -H "column_separator:," http://192.168.88.13:8030/api/test_db/test_streamload/_stream_load

This curl works in cmd, postman and go app but not works in C#, node, python. The error: [NOT_AUTHORIZED]no valid Basic authorization

使用 Session 保持授权信息(防止重定向时丢失 Authorization)

headers = {
    "Expect": "100-continue",
    'Content-Type': 'text/plain; charset=UTF-8',
    "merge_type": "APPEND",
    "format": "csv_with_names",
    "column_separator": ",",
}
auth = HTTPBasicAuth(username, password)
session = requests.sessions.Session()
session.should_strip_auth = lambda old_url, new_url: False  # **禁用 requests 的自动去掉 Authorization 头部的功能**

# 上传文件
file_path = "test.csv"
with open(file_path, "rb") as file:
    resp = session.request('PUT', url=url, data=file, headers=headers, auth=auth)

yanue avatar Mar 25 '25 09:03 yanue

curl --location-trusted -u root -T _data.csv -H "label:20" -H "format:csv_with_names" -H "Expect:100-continue" -H "column_separator:," http://192.168.88.13:8030/api/test_db/test_streamload/_stream_load This curl works in cmd, postman and go app but not works in C#, node, python. The error: [NOT_AUTHORIZED]no valid Basic authorization

使用 Session 保持授权信息(防止重定向时丢失 Authorization)

headers = {
    "Expect": "100-continue",
    'Content-Type': 'text/plain; charset=UTF-8',
    "merge_type": "APPEND",
    "format": "csv_with_names",
    "column_separator": ",",
}
auth = HTTPBasicAuth(username, password)
session = requests.sessions.Session()
session.should_strip_auth = lambda old_url, new_url: False  # **禁用 requests 的自动去掉 Authorization 头部的功能**

# 上传文件
file_path = "test.csv"
with open(file_path, "rb") as file:
    resp = session.request('PUT', url=url, data=file, headers=headers, auth=auth)

这个有用

sunmingqiaa avatar May 14 '25 06:05 sunmingqiaa