简体   繁体   English

python请求dynatrace SAAS url超过最大重试次数

[英]Python requests Max retries exceeded with dynatrace SAAS url

Trying to get User session data from Dynatrace SAAS using python3 script. 尝试使用python3脚本从Dynatrace SAAS获取用户会话数据。 The get Request is giving me error Max retries exceeded with url: Failed to establish a new connection: get Request给我错误Max retries exceeded with url: Failed to establish a new connection:

I'm not sure if I'm passing the token or proxy wrong. 我不确定是否传递令牌或代理错误。

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)

ERR0R ERR0R

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',))

BUT I'm able to get data using CURL with proxy from same machine. 但是我能够使用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

Thanks in advance! 提前致谢!

Are you sure that proxy is under http not https? 您确定代理位于http而非https下吗? If so, try sending api-token as: 如果是这样,请尝试按以下方式发送api令牌:

 headers={'Authorization': r'Api-Token XXXXXXXX'}

or 要么

 headers={'Authorization': r'XXXXXXXX'}

prefix r assures that you are sending raw string data. 前缀r确保您正在发送原始字符串数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM