Base64 Encode/Decode Visual Studio Extension

API, Extensions, Visual Studio
If you’ve followed any of the API articles that I’ve published then you know that anytime we have the need to include a Personal Access Token (PAT) as part of the Authorization header we have to Base64-encode it first. While it’s pretty easy to jump into your favorite search engine and find an online Base64 encoder (Bing has one built into the search engine!) sometimes it’s nice to not have to leave the Visual Studio IDE. For this reason, I created a simple Visual Studio extension that can Base64 encode/decode text.The add-in is pretty easy to use and shows up as a tool window that you can dock wherever you like. In the screenshot below, I have it docked at the bottom alongside the Output and Error List windows.To use…
Read More

Adding VSTS-Users to VSTS-Tools Samples

API, Visual Studio Team Services
It’s been about two years since I originally created the VSTS-Tools project on GitHub. The original release had two command-line tools included with it:VSTS-Get – CLI to download a single file or entire folder tree from VSTS (only Git is supported at this time). VSTS-Keep – CLI to set (or remove) the “Retain Indefinitely” retention flag for a given build. Not only were the tools meant to be somewhat useful (I used them then and still use them today) but they were also meant to act as yet another set of examples on how you might make use of the Visual Studio Team Services (VSTS) APIs.Recently, I posted some examples on how to get a list of VSTS users via API calls. For the sake of completeness, I have now…
Read More

Get a List of VSTS Users with APIs

API, VSTS
So, I’ve recently been preparing to switch our organization’s VSTS accounts over to be backed by Azure Active Directory and I have a need to export a list of all VSTS users within our accounts. After getting some assistance from the Visual Studio product group (thanks!) I was able to make use of the Member Entitlement Management API for VSTS. Since it’s been a while since I’ve done a VSTS API post I thought I’d share how to get a list of VSTS users (and other related information) using this API.PostmanPreviously, I’ve used Fiddler to quickly test API calls. In this post, I will use Postman to do the same. While Fiddler has some great features I like the simplicity of Postman’s user interface. If you’ve not used Postman, I…
Read More

Tulsa TechFest–Slides

API, Conferences, Extensions, Visual Studio Team Services
I first presented at the Tulsa TechFest in 2007, the second year for the conference. Since then I have only missed presenting one or two times (that I can recall). My oldest son (12) was able to attend this year as well and he really enjoyed the Gaming/Dev/Design track! The conference is really done well. I recommend you check it out next year if you’re in the area.This year, I had the pleasure to present two talks:Using REST with VSTS & TFSTeam Foundation Server (TFS) has been around for over a decade now(!) and Visual Studio Team Services (VSTS) has been around for several years. One of the reasons TFS/VSTS has been successful for so many years lies in the extensibility model provided by Microsoft. VSTS/TFS provides a large set…
Read More

Creating a File in VSTS with APIs

API, Visual Studio Online
Following along the same line as some of the previous API examples I've posted I thought I'd post an example on how to make use of the VSTS APIs to create a new file in a VSTS-based Git repo. This can be handy if you need to get a file into VSTS but don't want to mess around with calling out to the Git command line or making use of various Git libraries. If you're new to calling the VSTS REST APIs or you are new to this series of articles then I would recommend you check out the other articles in this series before getting started. For our example (of creating a new file) there are two VSTS APIs that must be utilized: the refs API and the pushes…
Read More

VSTS-Tools now on GitHub

API, Utilities, Visual Studio Online
Several of the past few posts that I have published have revolved around various Visual Studio Team Services (VSTS) REST API calls (you can click on the “View API Articles” button to the right to view the list of articles). Rather than relying purely on blog posts to provide example source code for these REST API calls, I thought I’d start making them available in a GitHub repo.Introducing VSTS-Tools!You can find the initial release on GitHub here: https://github.com/jbramwell/VSTS-ToolsThe initial release contains code examples for two command-line utilities:VSTS-Get – CLI to download a single file or entire folder tree from VSTS (only Git is supported at this time).VSTS-Keep – CLI to set (or remove) the “Retain Indefinitely” retention flag for a given build.You can find documentation on how to run the…
Read More

Download a File using VSTS REST APIs

API, Visual Studio Online
Adding yet another post related to Visual Studio Team Services (VSTS) REST APIs, I thought I’d cover an example of how to download a file from a Git repo in VSTS using the REST APIs (I will cover TFVC-based repositories in another post). In the example below, I will be using C# to make the API calls. However, you can use whatever approach makes the most sense for you (e.g. JavaScript, PowerShell, etc.).If you are new to calling the VSTS REST APIs or you are new to this series of articles then I would recommend on clicking the View API Articles link above to get started.Rather than spend time on how to authenticate with the VSTS APIs or how to deserialize API results into POCOs, I will simply highlight the…
Read More

Calling VSTS APIs with PowerShell

API, Visual Studio Online
Continuing along with my other various examples of VSTS API calls, I thought I’d include an example on how to call a Visual Studio Team Services REST API using PowerShell.To provide a concrete example, consider this scenario:We use VSTS-based builds to build our projects and create artifacts (e.g. web apps/services, binaries, etc.). We then make use of Octopus Deploy to deploy our artifacts into our various environments (e.g. development, test, production, etc.). Once these artifacts have been deployed to the production environment, we’d like to keep them around indefinitely.As you are likely aware, VSTS has a default retention policy on builds of 10 days with a maximum retention of 30 days. That is, unless you manually switch the retention for a build to “Keep Forever”. This can be accomplished easily…
Read More

Discovering VSTS APIs

API, Visual Studio, Visual Studio Code, Visual Studio Online
Building on our current theme of Visual Studio Team Services (VSTS) API calls, let’s take a look at discovering what APIs are available.The likely starting point for figuring out VSTS APIs is the REST API Reference for VS Team Services and TFS. Here you can view the various information and examples for the APIs currently exposed by VSTS (and TFS). The APIs are broken out into major categories with each category including links to the various resources provided by their respective APIs as shown in the excerpt below:If you’re like me, however, you might enjoy viewing the available APIs just a little bit closer to the “metal”. This is relatively simple with VSTS because Microsoft has implemented the HTTP OPTIONS method. While you wouldn’t necessarily want to use the OPTIONS…
Read More

Calling VSTS APIs with C#

API, Visual Studio, Visual Studio Online
In the last API-related article, Personal Access Tokens and VSTS APIs, we looked at how we can use Fiddler, along with a Personal Access Token (PAT), to query the Visual Studio Team Services (VSTS) REST APIs. In this post, we’ll take a look at how we can use a 3rd party Fiddler extension, Request to Code, along with the “Paste JSON as Classes” Visual Studio feature to jump start the process of calling VSTS APIs with C#. Pre-Requisites – Install the Extension Before we get started we must make sure we’ve installed the Fiddler extension Request to Code. On the extension page, click on the download link to download the extension. It will come down as a ZIP file that contains a DLL along with a few other files. To…
Read More