我写了一篇论文,摘述了ADO query的成果。
def get_query_results(connection, project_name,query_id):
Gets the result of a query in ADO
results = []
try:
wit_client = connection.clients.get_work_item_tracking_client()
result = wit_client.query_by_id(query_id)
work_items = result.work_items
for work_item in work_items:
work_item_details = wit_client.get_work_item(id=work_item.id, fields=["System.Id", "System.Title","System.AssignedTo"], expand="Relations,Fields")
results.append({"id": work_item_details.fields[ System.Id ], "title": work_item_details.fields[ System.Title ], "assigned_to": work_item_details.fields[ System.AssignedTo ]})
except Exception as e:
logger.exception(f Error fetching repositories from {project_name}: {str(e)} )
return results
但是,尽管在指定机构内有许多可用的领域,例如“签署协议”,但似乎我不能获得<>签署<>的>协议>。
results.append({"id": work_item_details.fields[ System.Id ], "title": work_item_details.fields[ System.Title ], "assigned_to": work_item_details.fields[ System.AssignedTo ]})
KeyError: System.AssignedTo
- how can I fix this ?
- how can I retrieve the available fields instead of just guessing ?
感谢您的帮助