Skip to content

How to query work items once and get desired fields #496

Open
@gp-bma

Description

@gp-bma

Hi There, I tried to use the following codes to execute my query with wiql. However, it depends on two times api calls, one is query_by_wiql and the other is get_work_items. In the first method, it will get all the ids (but no other fields), in the later one, it will get work items based on the ids returned in the first method. My question is that is there a way to directly query and get my desired fields in just one call?

credentials = BasicAuthentication('', api_token)
connection = Connection(base_url=server, creds=credentials)
client = connection.clients.get_work_item_tracking_client()
wiql = Wiql(query=query)
wiql_results = client.query_by_wiql(wiql, top=100).work_items
if wiql_results:
    ids = [str(res.id) for res in wiql_results]
    work_items = client.get_work_items(ids, fields=fields)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions