
We are trying to create Web data connector for Jira using Python, But getting error. Below is the code. Can someone help us here.
import os
import requests
import json
import urllib3
import pandas as pd
from jira import JIRA, JIRAError
# Jira API endpoint and authentication details
jira_url = 'https://jira.test.com/rest/api/3'
username = 'uname'
password = 'password' # Use API token instead of your password
headers = {
'Accept': 'application/json',
}
def fetch_jira_data(jira_query):
auth = (username, password)
response = requests.get(f'{jira_url}/{jira_query}', headers=headers, auth=auth)
if response.status_code == 200:
data = response.json()
return data
else:
print(f'Failed to fetch data. Status code: {response.status_code}')
return None
data =requests.get(url='https://jira.test.com/rest/api/3',timeout=300)
project_key = 'WPROG2-18'
jira_query = f'project/{project_key}'
data = fetch_jira_data(jira_query)
if data:
df = pd.DataFrame(data)
print(df)
df.head()
df.tail()
print(df)
df.head(1)
@Shashank Kumar
Hi, are you using Table Extensions?
https://help.tableau.com/current/online/en-us/tc_table_extensions.htm
If so, you can add at the end:
return df.to_dict(orient='list')
In the other hand, you may opt to run externally your python code, and use pantab to generate a hyper file, it is really easy:
https://pantab.readthedocs.io/en/latest/examples.html
If this post resolves the question, would you be so kind to "Select as Best"?. This will help other users find the same answer/resolution and help community keep track of answered questions. Thank you.
Regards,
Diego Martinez
Tableau Visionary and Forums Ambassador