Trying to login into JIRA account using rest API in python..getting error 404

Himani Gupta May 19, 2020

I wanted to download logs attach to issue using python script.For that I am trying to login into JIRA rest API using below command:

jira_object=jira.JIRA(options=options,basic_auth=(username,password))

where options={'server':server}, server= http://"jiraip"/issue

When running this code getting below error:

jira_object=jira.JIRA(basic_auth=(username,password),options=options)
File "C:\Users\himani.g2\AppData\Local\Programs\Python\Python37-32\lib\site-
ckages\jira\client.py", line 472, in __init__
si = self.server_info()
File "C:\Users\himani.g2\AppData\Local\Programs\Python\Python37-32\lib\site-
ckages\jira\client.py", line 2133, in server_info
j = self._get_json('serverInfo')
File "C:\Users\himani.g2\AppData\Local\Programs\Python\Python37-32\lib\site-
ckages\jira\client.py", line 2549, in _get_json
r = self._session.get(url, params=params)
File "C:\Users\himani.g2\AppData\Local\Programs\Python\Python37-32\lib\site-
ckages\jira\resilientsession.py", line 151, in get
return self.__verb('GET', url, **kwargs)
File "C:\Users\himani.g2\AppData\Local\Programs\Python\Python37-32\lib\site-
ckages\jira\resilientsession.py", line 147, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "C:\Users\himani.g2\AppData\Local\Programs\Python\Python37-32\lib\site-
ckages\jira\resilientsession.py", line 57, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError: JiraError HTTP 404 url: http://"jiraip"/iss
/rest/api/2/serverInfo
text: <!DOCTYPE html><html><head><title>Apache Tomcat/8.5.9 - Error re
rt</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color
hite;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sa
-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:T
oma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} bod
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {f
t-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {fon
family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a
color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76
order:none;}</style> </head><body><h1>HTTP Status 404 - </h1><div class="line"
/div><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>descri
ion</b> <u>The requested resource is not available.</u></p><hr class="line"><h
Apache Tomcat/8.5.9</h3></body></html>

response headers = {'Content-Type': 'text/html;charset=utf-8', 'Conten
Language': 'en', 'Content-Length': '984', 'Date': 'Tue, 19 May 2020 18:11:00 G
'}
response text = <!DOCTYPE html><html><head><title>Apache Tomcat/8.5.9
Error report</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-s
if;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahom
Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {fon
family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:
px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:wh
e;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D7
} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-siz
12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-col
:#525D76;border:none;}</style> </head><body><h1>HTTP Status 404 - </h1><div cl
s="line"></div><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p
b>description</b> <u>The requested resource is not available.</u></p><hr class
line"><h3>Apache Tomcat/8.5.9</h3></body></html>

 

When I am trying to use the same jiraIP using request.get method then it is working fine.

jira_query = 'filter%20in%20(' + filterNumber + ')' #Jira query which we will fetch me issues from that filter
final_url = jiraapi+ '/rest/api/latest/search?jql=' + jira_query #Final url to ping to

with requests.get(final_url, auth = (jira_username, jira_password)) as f:

 

Please help me with the above issue.Why it is not working with restAPI.

 

 

1 answer

0 votes
said kouzibry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 24, 2021

I notice in the error message you are getting the following URL :HTTP 404 url: http://"jiraip"/iss
/rest/api/2/serverInfo

How do you get this URL ? Are you using a custom context path for Jira ?

Make sure the "iss" part of the URI is correct.

Suggest an answer

Log in or Sign up to answer