Created
May 18, 2020 23:15
-
-
Save boxrick/057bcb238590ab3504e19601b8178f65 to your computer and use it in GitHub Desktop.
Azure Devops - Python API - Simple request example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests.auth import HTTPBasicAuth | |
import logging | |
import sys | |
import json | |
def getApi(uri, token): | |
try: | |
resp = requests.get(uri,auth=HTTPBasicAuth('',token)) | |
parsed = json.loads(resp.text) | |
print(json.dumps(parsed, indent=4, sort_keys=True)) | |
except Exception as e: | |
logging.error(e) | |
# Pass in PAT token or $(System.AccessToken) as an argument and run an API request | |
getApi(uri='https://vsrm.dev.azure.com/<ORG>/<PROJECT>/_apis/release/definitions/?api-version=5.1', token=sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There seems to be nothing on the internet about this just stupid complicated examples. This is a really basic Python API call to the AzureDevOps API. Enough to get you started.