Skip to content

query_by_wiql throws exception #510

Open
@partmachine

Description

@partmachine

query_by_wiql throws exception:

'Unable to build a model: ("Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'", AttributeError("'str' object has no attribute 'get'")), DeserializationError: ("Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'", AttributeError("'str' object has no attribute 'get'"))', DeserializationError("Unable to deserialize to object: type, AttributeError: 'str' object has no attribute 'get'", AttributeError("'str' object has no attribute 'get'")))

I'm trying to get a list of backlog items ids using the following function:

def get_backlog_item_ids(self, project_name, item_type="Product Backlog Item"):
try:
work_item_tracking_client = self.connection.clients.get_work_item_tracking_client()
wiql_query = f"""
SELECT [System.Id]
FROM WorkItems
WHERE [System.TeamProject] = '{project_name}'
AND [System.WorkItemType] = '{item_type}'
ORDER BY [System.Id]
"""
query_result = work_item_tracking_client.query_by_wiql(wiql=wiql_query)
work_item_ids = [item.id for item in query_result.work_items]
print(f"Retrieved {len(work_item_ids)} backlog item IDs from project '{project_name}'.")
return work_item_ids
except Exception as e:
print(f"Error retrieving backlog item IDs: {str(e)}")
return []


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