Friday, 10 June 2022

how to add azure devops iteration path option with python api

I have an Azure DevOps project with multiple iteration paths: image

If I use this Azure Python API (https://github.com/microsoft/azure-devops-python-api) to create a new work item and set /fields/System.IterationPath to have a value that already exists like RTC-ADS\PI28\Sprint 28-3 it will create the work item with no issue.

But if I try to create a work item with an iteration that does not yet exist such as RTC-ADS\PI27 it will fail with an error

ERROR:root:Error creating ADS work item: TF401347: Invalid tree name given for work item -1, field 'System.IterationPath'.

I could create PI27 manually in my Azure Project settings, but is there a way I can use this Azure Python API to create a new iteration value for PI27 by making a POST request or something?

I have found documentation supporting how to do so I believe: https://docs.microsoft.com/en-us/rest/api/azure/devops/work/iterations/post-team-iteration?view=azure-devops-rest-6.0

But is it possible to add a new iteration value using this API? https://github.com/microsoft/azure-devops-python-api

Thanks

EDIT

I've been trying to get a POST request working to add a new iteration path:

pat = CONFIG.personal_access_token
authorization = str(base64.b64encode(bytes(':'+pat, 'ascii')), 'ascii')

headers = {
    'Accept': 'application/json',
    'Authorization': 'Basic '+authorization
}

response = requests.post(
    url="https://dev.azure.com/ADSP-Org-A03/RTC-ADS/_apis/work/teamsettings/iterations?api-version=6.0&iteration=apple&startDate=2021-01-01&endDate=2021-01-11", 
    headers=headers
)

print(response.text)

But this results in an error:


{"$id":"1","innerException":null,"message":"Value cannot be null.\r\nParameter name: iteration","typeName":"System.ArgumentNullException, mscorlib","typeKey":"ArgumentNullException","errorCode":0,"eventId":0}

which i am trying to solve, is my request formatted incorrectly? I cant find a working example online for adding an iteration path to an ADS project



from how to add azure devops iteration path option with python api

No comments:

Post a Comment