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 : Trust network share to load modules & ps1

Problem Do you have a central network share, where you store all the scripts or PowerShell modules ? What happens if you try to run the script from a network share ? or if you have scripts (local) which invoke scripts or import PowerShell modules stored on this network share ? Well you would see a security warning like below (Note - I have set execution policy as 'Unrestricted' not 'bypass' here): Run a .ps1 from the network share Well this is a similar warning, which you get when you download scripts from Internet. As the message says run Unblock-File cmdlet to unblock the script and then run it, let's try it.