To add a comment using the Python API in Azure DevOps, you can use the following code:
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
# Your organization URL
organization_url = 'https://dev.azure.com/myOrganization'
# Personal access token for authentication
personal_access_token = 'myToken'
# Create a connection to the Azure DevOps organization
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
# The team project where the work item is located
team_project = 'MyProject'
# The ID of the work item
work_item_id = 1234
# The comment text
comment_text = 'This is a comment'
from azure.devops.v6_0.work_item_tracking import WorkItemTrackingHttpClient
from azure.devops.v6_0.work_item_tracking.models import CommentCreate
# Get a reference to the WorkItemTrackingHttpClient
wit_client = connection.clients.get_work_item_tracking_client()
# Create a CommentCreate object with the comment text
comment = CommentCreate(text=comment_text)
# Add the comment to the work item
wit_client.add_comment(comment, team_project, work_item_id)
This will add a new comment to the specified work item in Azure DevOps using the Python API.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-28 02:03:12 +0000
Seen: 10 times
Last updated: May 28 '23
How can I set up Gunicorn with a Django Project?
Looking for a Python Module that finds Tags for a Text describing its Content
Need a Function in Python to remove entries less than 2 digits from an Array
How can I convert a Document in Python?
How can I program a Loop in Python?
How can I enable Python Code Highlighting in Askbot?