Sorry to bother you, I need help. I tried calling the Jira Cloud API for the first time, but it always prompted 'timeout'. I can not find the reason. Is it an authentication issue or is api function not open in console? Besides, I found that the api can be displayed when I input it on the web page. The code is as followed:
The error is as followed:
url: https://gm-sdv.atlassian.net/rest/api/3/field
Traceback (most recent call last): File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connection.py", line 171, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw) File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection raise err File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection sock.connect(sa) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen chunked=chunked) File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request self._validate_conn(conn) File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 849, in _validate_conn conn.connect() File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connection.py", line 314, in connect conn = self._new_conn() File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connection.py", line 176, in _new_conn (self.host, self.timeout)) urllib3.exceptions.ConnectTimeoutError: (, 'Connection to gm-sdv.atlassian.net timed out. (connect timeout=5)') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\adapters.py", line 445, in send timeout=timeout File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen _stacktrace=sys.exc_info()[2]) File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\util\retry.py", line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='gm-sdv.atlassian.net', port=443): Max retries exceeded with url: /rest/api/3/field (Caused by ConnectTimeoutError(, 'Connection to gm-sdv.atlassian.net timed out. (connect timeout=5)')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\cz2f2s\Desktop\GMPI_Tools\GMPI_INFO_TOOL\GMPI_JIRA_TOOL_FOR_CLOUD\ExportTestExecution.py", line 360, in SearchJiraID(JiraID, Email, Token) File "C:\Users\cz2f2s\Desktop\GMPI_Tools\GMPI_INFO_TOOL\GMPI_JIRA_TOOL_FOR_CLOUD\ExportTestExecution.py", line 28, in SearchJiraID response = Api.get_data() File "C:\Users\cz2f2s\Desktop\GMPI_Tools\GMPI_INFO_TOOL\GMPI_JIRA_TOOL_FOR_CLOUD\Session.py", line 108, in get_data response = requests.request("GET", self.url, headers=self.headers, auth=auth, timeout=self.timeout) File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 512, in request resp = self.send(prep, **send_kwargs) File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 622, in send r = adapter.send(request, **kwargs) File "C:\Users\cz2f2s\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\adapters.py", line 501, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='gm-sdv.atlassian.net', port=443): Max retries exceeded with url: /rest/api/3/field (Caused by ConnectTimeoutError(, 'Connection to gm-sdv.atlassian.net timed out. (connect timeout=5)'))
It shows normal in web page:
I guarantee that my API token is fine, but it seems that there is no problem with webpage authentication.
Thank a millions !
Hi @Mingda Cai
Welcome to Atlassian Community.
Your assumption here is correct, it is not the Authentication issue, it is caused by time out issue, increase the time out, or try by catching the timeout error.
try:
#defined request goes here
except requests.exceptions.ReadTimeout:
# Set up for a retry, or continue in a retry loop
example as below:-
try:
requests.post(url, headers, timeout=10)
except requests.exceptions.Timeout:
print "Timeout occurred"
Vikram P
Thank you for your reply. The cause of this issue has been identified. It was due to a problem with our GM company's agency service, which resulted timeout.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.