Skip to content

Instantly share code, notes, and snippets.

@boxrick
Created May 18, 2020 23:15
Show Gist options
  • Save boxrick/057bcb238590ab3504e19601b8178f65 to your computer and use it in GitHub Desktop.
Save boxrick/057bcb238590ab3504e19601b8178f65 to your computer and use it in GitHub Desktop.
Azure Devops - Python API - Simple request example
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])
@boxrick
Copy link
Author

boxrick commented May 18, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment