Reputation: 169
Trying to create a new workitem in VSTS via Python API access and I cant find anywhere in the documents on how to create a new workitem in Python. I'm sure it's fairly simple but I can't seem to find it in the documentation.
Upvotes: 6
Views: 16926
Reputation: 1241
Here is a solution for creating a new task, that relies only on the requests
library:
import os
import requests
# See link down below to generate your Private Access Token
AZURE_DEVOPS_PAT = os.getenv('AZURE_DEVOPS_PAT')
url = 'https://dev.azure.com/xxxxxxxxxxx/xxxxxxxxxxxx/_apis/wit/workitems/$task?api-version=5.1'
data = [
{
"op": "add",
"path": "/fields/System.Title",
"value": "Sample task"
}
]
r = requests.post(url, json=data,
headers={'Content-Type': 'application/json-patch+json'},
auth=('', AZURE_DEVOPS_PAT))
print(r.json())
See Create personal access tokens to authenticate access
Upvotes: 11
Reputation: 51093
Please kindly refer this official Azure DevOps Python API doc.
It contains Python APIs for interacting with and managing Azure DevOps. These APIs power the Azure DevOps Extension for Azure CLI. To learn more about the Azure DevOps Extension for Azure CLI, visit the Microsoft/azure-devops-cli-extension repo.
Here is some example code for creating work item in python.
Upvotes: 6