{"info":{"_postman_id":"45653cc8-a969-4863-baa9-2dcde2e58dd1","name":"Azure DevOps API Documentation","description":"<html><head></head><body><h1 id=\"overview\">🌐 Overview</h1>\n<p>This API provided by Microsoft provides a reliable and well documented solution to automating Azure DevOps (ADO) functionality. In our case it is most useful for pipelines that run on continuous integration (CI) events, such as a commit or pull request. Or, in gaining insight into the state of a team in an ADO organisation.</p>\n<p>This guide is for someone without much experience using APIs like myself when I started here. The sections are based on a certain piece of functionality, not a section of the API.</p>\n<p>Hopefully you will enjoy using the API it as much as I did 😎</p>\n<hr>\n<h1 id=\"setup\">⚙️ Setup</h1>\n<p><strong>Language</strong></p>\n<p>It is reccomended that you use Powershell or BASH for performing API requests as they are the two scripting languages that are default on Windows and Linux runners respectively. Also, they are easy to test on your local machine when diagnosing your own probelms or those of other team members. The other option that comes pre-installed on Github's runners is Python. This is just as good for sending requests, however you may prefer to develop pipelines in one language instead of swapping for scripts and skeleton code in YAML configurations.</p>\n<p><a href=\"https://www.itprotoday.com/powershell/getting-started-with-rest-apis-in-powershell\">Beginner Powershell REST API</a></p>\n<p><a href=\"https://www.freecodecamp.org/news/how-to-start-using-curl-and-why-a-hands-on-introduction-ea1c913caaaa/\">Beginner CURL REST API (BASH)</a></p>\n<p><a href=\"https://www.dataquest.io/blog/api-in-python/\">Beginner Python REST API</a></p>\n<hr>\n<h1 id=\"authentication\">🔐 Authentication</h1>\n<p>The ADO API uses OAuth 2.0 bearer tokens for authenticating requests. Tokens should not be confused with keys/certificates which are verified with cryptographic methods. Tokens are like passwords except that they are regularly changed and passed to different bearers. ADO refers to these tokens as Personal Access Tokens (PAT) and you can create them through the web interface as shown below:</p>\n<p>1. Find the <em>User settings</em> icon at the top right of the page.</p>\n<img src=\"https://content.pstmn.io/e239ffe3-3c4d-417e-9e95-f5a3e20e6258/U2NyZWVuc2hvdCAyMDI0LTEyLTE4IGF0IDcuNDIuMjDigK9QTS5wbmc=\" width=\"372\" height=\"45\">\n\n<p>2. From the drop down, select <em>Personal access tokens.</em></p>\n<img src=\"https://content.pstmn.io/df3a8b92-f28b-4b5b-8717-9aeed69e99c7/U2NyZWVuc2hvdCAyMDI0LTEyLTE4IGF0IDcuNTQuNDjigK9QTS5wbmc=\" width=\"194\" height=\"300\">\n\n<p>3. On the next page, select <em>New token</em>.</p>\n<img src=\"https://content.pstmn.io/efd0ec5f-3559-438b-bdec-94b113f83d91/U2NyZWVuc2hvdCAyMDI0LTEyLTE4IGF0IDcuNTcuMTXigK9QTS5wbmc=\" width=\"661\" height=\"243\">\n\n<p>4. You should set the token to expire at the end of the current semester (90 days works well for this).</p>\n<img src=\"https://content.pstmn.io/9ff5318b-2d7c-4c00-b7cf-13c089fbcc50/U2NyZWVuc2hvdCAyMDI1LTAxLTAzIGF0IDExLjMwLjU34oCvQU0ucG5n\">\n\n<p>5. For good security the token should have as little privileges as possible. Below is the selection used for the pull request automation pipeline. It only needs to create work items.</p>\n<img src=\"https://content.pstmn.io/bd995dcb-f611-4e51-8af9-5e7f3c9c7b99/U2NyZWVuc2hvdCAyMDI1LTAxLTAzIGF0IDExLjMxLjQ54oCvQU0ucG5n\" width=\"326\" height=\"95\"></body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"🌐 Overview","slug":"overview"},{"content":"⚙️ Setup","slug":"setup"},{"content":"🔐 Authentication","slug":"authentication"}],"owner":"40407894","collectionId":"45653cc8-a969-4863-baa9-2dcde2e58dd1","publishedId":"2sAYJ7hzSB","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EB7463"},"publishDate":"2025-01-03T01:18:55.000Z"},"item":[{"name":"Create Tasks From Pull Requests","item":[{"name":"Work Items - Create","id":"0310e111-39a1-4cc9-b124-96066a2328fe","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[],"body":{"mode":"raw","raw":"[\n    {\n        \"op\": \"add\",\n        \"path\": \"/fields/System.Title\",\n        \"value\": \"$PR_TITLE\"\n    },\n    {\n        \"op\": \"add\",\n        \"path\": \"/fields/System.AssignedTo\",\n        \"value\": \"$User\"\n    },\n    {\n        \"op\": \"add\",\n        \"path\": \"/fields/System.Description\",\n        \"value\": \"$TASK_DESC\"\n    },\n    {\n        \"op\": \"add\",\n        \"path\": \"/fields/System.AreaPath\",\n        \"value\": \"$AREA_PATH\"\n    }\n]","options":{"raw":{"language":"json"}}},"url":"?ORGANISATION=redbackoperations&PROJECT=Cybersecurity&TEAM=SecDevOps&API_VERSION=7.1&NOTIFY=supressNotifications={true}&TYPE=task","description":"<p>The body of the request is a JSON Patch and must include the operation <strong>op</strong>, path <strong>path,</strong> value <strong>value</strong>. In this case the operation is always <em>add</em> and the path is a directory like representation of the field.</p>\n","urlObject":{"query":[{"key":"ORGANISATION","value":"redbackoperations"},{"key":"PROJECT","value":"Cybersecurity"},{"key":"TEAM","value":"SecDevOps"},{"description":{"content":"<p>For this specific use of the API there was a lot of version compatability. Make sure to check if there are any changes in Microsoft's documentation before creating your own requests.</p>\n","type":"text/plain"},"key":"API_VERSION","value":"7.1"},{"description":{"content":"<p>This tells Azure DevOps not to notify the person that the task is assigned to. This is ideal so that reviewers are not flooded with pull request notifications. Instead they are all contained in one central location.</p>\n","type":"text/plain"},"key":"NOTIFY","value":"supressNotifications={true}"},{"description":{"content":"<p>Your options for this field vary based on which process type you have selected for your project. For example Agile, Scrum, CMMI.</p>\n","type":"text/plain"},"key":"TYPE","value":"task"}],"variable":[]}},"response":[],"_postman_id":"0310e111-39a1-4cc9-b124-96066a2328fe"}],"id":"f89e7c41-01d6-4e7b-a831-4def3176f2cc","description":"<p>The foundation for the pull request task automation is the work item section of the API. It is an HTTP POST operation which includes pretty much every field you could need except for task comments (requires subsequent requests).</p>\n<p>It uses the <em>/wit/workitems/</em> area of the API.</p>\n","_postman_id":"f89e7c41-01d6-4e7b-a831-4def3176f2cc"}],"event":[{"listen":"prerequest","script":{"id":"8928bf20-740c-4901-8448-94e11ddbca45","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"905951e3-2301-4612-8b4a-1d8af8821abe","type":"text/javascript","exec":[""]}}],"variable":[{"key":"baseUrl","value":"https://farming-simulator.pstmn.io","disabled":true},{"key":"token","value":"T0K3N","type":"string","disabled":true}]}