尝试使用 python3 脚本从 Dynatrace SAAS 获取用户会话数据。获取请求给了我错误Max retries exceeded with url: Failed to establish a new connection:
我不确定我是否传递了错误的令牌或代理。
import requests
from requests.exceptions import ConnectionError
try:
response = requests.get('https://jbu0001.live.dynatrace.com/api/v1/userSessionQueryLanguage/table?SELECT%20*%20from%20usersession&explain=true',
headers={'Authorization': 'Api-Token XXXXXXXX'}, proxies={'http': 'http://proxy.com:PORT'}, verify=False)
if response.status_code == 200:
response.text
except ConnectionError as e:
print(e)
错误0R
HTTPSConnectionPool(host='jbu0000.live.dynatrace.com', port=443): Max retries exceeded with url: /api/v1/userSessionQueryLanguage/table?SELECT%20*%20from%20usersession&explain=true (Caused by NewConnectionError('<urllib3.conne
ction.VerifiedHTTPSConnection object at 0x00000160212D5B38>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',))
但是 我可以使用 CURL 和来自同一台机器的代理来获取数据。
curl -X GET "https://jbu00XXX.live.dynatrace.com/api/v1/userSessionQueryLanguage/table?query=select%20*%20from%20usersession&explain=true" -H "accept: application/json" -H "Authorization: Api-Token XXXXXXXXX" --proxy http://proxy.com:PORT
提前致谢!