I have managed to connect to Azure DevOps via their API (thanks to this question that was raised) , and managed to get the output required detailing all work items recorded. However, I would like to convert the output into a dataframe.
def print_work_items(work_items):
for work_item in work_items:
print(
"{0} {1}: {2}".format(
work_item.fields["System.WorkItemType"],
work_item.id,
work_item.fields["System.Title"],
)
)
wit_client = connection.clients.get_work_item_tracking_client()
def get_TC_from_query(query):
query_wiql = Wiql(query=query)
results = wit_client.query_by_wiql(query_wiql).work_items
# WIQL query gives a WorkItemReference => we get the corresponding WorkItem from id
work_items = (wit_client.get_work_item(int(result.id)) for result in results)
#print_work_items(work_items)
dq_workitems = get_TC_from_query(
"""\
SELECT
[System.Id],
[System.WorkItemType],
[System.Title],
[System.State],
[System.AreaPath],
[System.AssignedTo]
FROM workitems
WHERE
[System.AreaPath] = 'Designated Area Path'
ORDER BY [System.Id] DESC
"""
)
df = pd.DataFrame(print_work_items(dq_workitems), columns=['Id','WorkItemType','Title',
'State','AreaPath','AssignedTo'])
print(df)
I am able to print out the work items onto the console but fail to populate the dataframe. Any thoughts/leads would be highly appreciated!