team_context problem
Hi,
I'm trying to use get_boards() method located in get_work_client()
first of all, I'm using get_all_teams() method located in get_core_client() to check project_id
after printing project_id I'm passing it to
get = work_client.get_boards()
but error appears
if team_context.project_id: AttributeError: 'str' object has no attribute 'project_id'
what should be passed to the method then?
@rilooth , can you provide a code snippet? Where are you getting team_context from?
Hi @tedchamb
I think I had a wrong thinking about the question.
The question is how to pass the team_context to the get_boards()
I was trying like this:
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
core_client = connection.clients_v5_1.get_core_client()
get_team = core_client.get_team("154f85b6-431a-43ed-b247-8446e5a18a76", "0fcf4689-2123-465f-88b0-de5e15c78b7a")
work_client = connection.clients_v5_1.get_work_client()
get = work_client.get_boards(get_team)
but now I have
AttributeError: 'WebApiTeam' object has no attribute 'team_id'
Is there any workaround for this?
btw. I'm trying to extract values for work items like 'Attributes' and 'Description' from Boards -> Work Items but I'm in the dark
get_teamreturns a WebApiTeam object. get_boards takes a TeamContext object. You will need to convert the WebApiTeam object into a TeamContext object, by doing something like this:
team_context = TeamContext()
team_context.project_id = get_team.project_id
team_context.team_id = get_team.id
get = work_client.get_boards(team_context)
or since you already know the ids, you can skip the get_team call and do this:
team_context = TeamContext()
team_context.project_id = "154f85b6-431a-43ed-b247-8446e5a18a76"
team_context.team_id = "0fcf4689-2123-465f-88b0-de5e15c78b7a"
get = work_client.get_boards(team_context)
Hi @tedchamb
thank you for your response. That worked for me. Do you have any idea if there is any method I can get text under work items fields like "Acceptance Criteria" or "Description"?
REST doc here: https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/get%20work%20item?view=azure-devops-rest-5.1
Hi @tedchamb get_boards attribute is a part of get_work_client() function. Could you confirm get_work_item attribute is a part of which source function. Im looking to get the Work Item ID, Name and the State(active/closed) of a Work Item in Azure Devops. I get error when i try this.
for board in wit_client.get_boards(team_ctx): pprint.pprint("Board ID " + board.id) pprint.pprint("Board Name " + board.name) print(board.get_work_item(projects.id)) The Error is BoardReferenceObject has no attribute get_work_item