Skip to main content

Azure DevOps Tips & Tricks - Find private REST APIs


Often working with Azure DevOps, I hit a wall trying to automate some tasks but there are no REST API's made public yet.

It was one of those task of automating creation of Environments in multi-stage YAML based pipelines in AzDO.



Quick research reveals that this has been requested in uservoice (please upvote).
Let's see one of the very simple ways to discover some of these APIs.


F12 Developer tools to rescue

Using your browser's developers tools you can actually inspect the HTTP requests being made while performing an action in the web portal.
Let's do this.

Let's click on the "Create Environment" button, fill out some dummy values, hit create and keep an eye on the network tab.



We see some activity, it might take you some time to walk through what happened but in this case the top activity named "environments" has the required details.

See below and note the URL & method used:

With a HTTP POST method we often specify a request JSON body. You can see those details in the same activity under "request payload". The request payload matches the input in the web form.


That's mostly it, fire up postman/PowerShell to make the API call to test this.

Invoke-RestMethod with Pwsh

Generate a Personal Access Token in AzDO, typically start with a short lived PAT token with full access and then nail down on the specific permissions you need.

Below is the code snippet, I used with AzDO to hit the REST API endpoint:


But when I execute the above code, it gives me an error
The error thrown is below:


Read the error message, it explains that the api-version is missing. Also, looking back at the capture and see where the api-version was specified.
It is clear that the api-version in specified in the headers, this means we can do the same in our code snippet from before and modify it to get working.

Here I go, this finally works and using the similar API endpoint I can fetch the environments as well (GET request).


Popular posts from this blog

Test connectivity via a specific network interface

Recently while working on a Private cloud implementation, I came across a scenario where I needed to test connectivity of a node to the AD/DNS via multiple network adapters.  Many of us would know that having multiple network routes is usually done to take care of redundancy. So that if a network adapter goes down, one can use the other network interface to reach out to the node. In order to make it easy for everyone to follow along, below is an analogy for the above scenario: My laptop has multiple network adapters (say Wi-Fi and Ethernet) connected to the same network. Now how do I test connectivity to a Server on the network only over say Wi-Fi network adapter?

PowerShell + SCCM : Run CM cmdlets remotely

Today I saw a tweet about using implicit remoting to load the Configuration Manager on my machine by Justin Mathews . It caught my eye as I have never really tried it, but theoretically it can be done. Note - The second tweet says "Cannot find a provider with the name CMSite", resolution to which is in the Troubleshooting section at the end.

PowerShell + WPF + GUI : Hide (Use) background PowerShell Console

Few years back, I had started wrapping my PowerShell scripts with some sort of GUI built using Windows Forms (used Primal Forms CE mostly). Things went fine for a while but then I stumbled across awesome posts by MVP Boe Prox on using WPF with PowerShell to do the same. (check Resources section) I had been procrastinating the idea of playing with WPF for a while but then had a great discussion with MVP Chendrayan (Chen) and got inspired to do it. One can use Visual Studio (Express Edition - which is free) to design the UI and then consume the XAML in PowerShell script...Isn't that Cool ! See resources section for links on that. Often when we write the Code to present a nice UI to the end user there is a PowerShell console running in the background. In this post I would like to share a trick to hide/show the background console window. This trick works with both Winforms and XAML. Note - PowerGUI & Visual Studio Express are absolutely FREE ! For the demo o...