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.
https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/create?view=azure-devops-rest-5.1
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With