Visual Studio App Center has a great API exposing most if not all of its functionality. This is useful for a ton of reasons, whether you want to integrate its app management functionality into your workflow in a custom way, or as in my case, use it to access analytics and display custom dashboards. You can of course export App Center Analytics data to blob storage or App Insights. For my purposes, I only needed access to a few aspects of data and also a more fine grained control, so chose to just call the API. The API is documented using Open API here. This post will take you through getting all of the API endpoints imported into Postman and even generate code to start calling them. The tooling has certainly come a long way since building API clients by hand!
Get the API Swagger
Import the Swagger into Postman
You can import Swagger into Postman by clicking the Import button at the top of the app. From here you choose the source of the Swagger via file, folder, link or raw text. This is how I discovered that simply pasting the App Center Swagger URL did not work, so I posted the raw json from the link above and it created a new collection containing all of the endpoints. Most of the endpoints do not have a general description so they end up having no title in Postman, making it difficult to tell one from another. The good thing is you can add your own title to your favorite endpoints and save them in the collection.
Make your first call
To authenticate your call to the API from Postman, you need to obtain a token and (I had to dig around online for this one) add a key named X-API-Token to the header of the call with a value of the token you obtained from App Center. Postman has a neat feature where you can store preset headers and add them to your calls, so I stored the token header as a preset so I can easily add them to new calls.
Generate client code
Now that you’re authenticated you can have Postman generate sample code for each endpoint. In my case I used the RestSharp code gen feature. To do that, click the code link (shown in the image above) while you’re in edit mode of a call and select your language. That’s it, you’re off and running!