i’m trying to make a simple API call from python to azure DevOps: just take the members of a team from an Azure DevOps project using the simple and yet elegant http library called Requests https://pypi.org/project/requests/.
Following this documentation from Azure to get the correct API https://learn.microsoft.com/en-us/rest/api/azure/devops/core/teams/get-team-members-with-extended-properties?view=azure-devops-rest-6.0&tabs=HTTP
Just a simple call to get the JSON response.
However, it is not working by simple making this on jupyter notebook:
import requests
response = requests.get(https://dev.azure.com/{organization}/_apis/projects/{projectId}/teams/{teamId}/members?api-version=6.0)
(of course, replacing the variables between { } with the right values)
The response code that is coming is 203 and not 200. Probably i’m missing something related to the authentication to the DevOps project. But on this microsoft documentation i cannot find something that explain how to overcome this. Anyone can help me? How can i make this request and get the response using python jupyter notebook?
Thanks!
2
Answers
Yeah. The issue was the authentication.
I found this sample code that solved my problem. Basically i needed to create an personal access token on the Devops project i want to access and them copy this token and paste on the pat variable. Then you just need to substitute the URL variable on the response.get method to make the request call to Azure Devops API. In my case, the URL was for the team members
Solved :) this is so good everyone wins.
You need to add your Auth: