使用 requests 时收到 404,但curl 工作正常

Dav*_*ve0 6 python python-requests

我正在使用请求从第 3 方门户获取一些 JSON。每当我使用 requests 时,我都会收到'{"Message":"Path not found"}'错误,但是使用 cURL 运行命令效果很好。这是 cURL 命令:

curl https://blah.com/api/v1/nodes --header 'Authorization: Bearer my-long-token-base64'

尝试使用 python3 / requests 来做到这一点,我有:

#convert token to base64
base64_token = base64.b64encode(bytes(access_token, 'utf-8'))
#convert to str
base64_token = base64_token.decode("utf-8")

api = 'https://blah.com/api/v1/nodes'
headers = {'Authorization': 'Bearer ' + base64_token,
'Accept': 'application/json'}
nodes = requests.post(api, headers=headers)
Run Code Online (Sandbox Code Playgroud)

每当我运行这个时,我的反应是'{"Message":"Path not found"}' 我认为这可能与base64令牌(这是必需的)有关,但很确定我已经正确地理解了这部分,否则我会得到401。

有什么想法吗?