{"id":1361,"date":"2014-05-12T09:00:00","date_gmt":"2014-05-12T09:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/bharry\/2014\/05\/12\/a-new-api-for-visual-studio-online\/"},"modified":"2024-03-20T14:59:30","modified_gmt":"2024-03-20T21:59:30","slug":"a-new-api-for-visual-studio-online","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/bharry\/a-new-api-for-visual-studio-online\/","title":{"rendered":"A new API for Visual Studio Online"},"content":{"rendered":"<p>The \u201cbig\u201d news that I announced at TechEd this week was a new API for accessing Visual Studio Online (and, in a future release, Team Foundation Server).\u00a0 This new API is based on REST, OAUTH, Json and Service Hooks \u2013 all standard web technologies broadly supported in the industry.\u00a0 The API is still currently in preview while we take feedback and refine it.<\/p>\n<p>The reason for the new API is we wanted to make it dramatically easier to integrate VS Online with other web based tools and to access VS Online from any mobile device \u2013 whether they are 3rd party commercial tools or custom ones you are building.\u00a0 Because we\u2019ve used the standard technologies, many integrations can be done simply by wiring up simple connections with a service like Zapier.\u00a0 And all connected devices \u2013 Android, iOS, Windows and more, have great support for working with services using these protocols.<\/p>\n<p>As an initial wave, we\u2019ve worked to provide specific integrations with 18 tools\/services and we\u2019ll add more in the future.\u00a0 Zapier enables basic integration with hundreds more.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/1830.image_thumb_66551F5B.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-15762\" src=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/1830.image_thumb_66551F5B.png\" alt=\"Image 1830 image thumb 66551F5B\" width=\"324\" height=\"394\" srcset=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/1830.image_thumb_66551F5B.png 324w, https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/1830.image_thumb_66551F5B-247x300.png 247w\" sizes=\"(max-width: 324px) 100vw, 324px\" \/><\/a><\/p>\n<h2>API Documentation<\/h2>\n<p>As part of rolling out these new APIs we\u2019ve created a set of web pages to document them.\u00a0 The new VS Online REST, OAuth and Service Hook documentation is here: <a title=\"http:\/\/www.visualstudio.com\/en-us\/integrate\/explore\/explore-vso-vsi\" href=\"http:\/\/www.visualstudio.com\/en-us\/integrate\/explore\/explore-vso-vsi\">http:\/\/www.visualstudio.com\/en-us\/integrate\/explore\/explore-vso-vsi<\/a><\/p>\n<p>We\u2019ve also taken the opportunity to create a consolidated landing page for all our Visual Studio, Team Foundation Server and Visual Studio Online content here: <a href=\"http:\/\/integrate.visualstudio.com\">http:\/\/integrate.visualstudio.com<\/a><\/p>\n<p>The docs have both good conceptual content and super simple API reference material like this section on how to get a work item with REST:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/0537.image_thumb_31B753D1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-15763\" src=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/0537.image_thumb_31B753D1.png\" alt=\"Image 0537 image thumb 31B753D1\" width=\"800\" height=\"476\" srcset=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/0537.image_thumb_31B753D1.png 800w, https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/0537.image_thumb_31B753D1-300x179.png 300w, https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/0537.image_thumb_31B753D1-768x457.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>To experiment with it, many of the APIs can be exercised directly from your browser.\u00a0 For instance, if I browse to <a title=\"https:\/\/minka.visualstudio.com\/_apis\/wit\/workitems\/73\" href=\"https:\/\/minka.visualstudio.com\/defaultcollection\/_apis\/wit\/workitems\/73\">https:\/\/minka.visualstudio.com\/defaultcollection\/_apis\/wit\/workitems\/73<\/a> (minka is my personal account), I get something that looks like this. The precise output format you get depends on what browser you use and what plugins you have installed but the content is the same regardless.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/8103.image_thumb_35C43254.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-15765\" src=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/8103.image_thumb_35C43254.png\" alt=\"Image 8103 image thumb 35C43254\" width=\"320\" height=\"497\" srcset=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/8103.image_thumb_35C43254.png 320w, https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/8103.image_thumb_35C43254-193x300.png 193w\" sizes=\"(max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<p>\u2026 I\u2019m not going to show the whole thing because it\u2019s pretty big \ud83d\ude42<\/p>\n<p>The docs also have some simple samples and we\u2019re busy working on more.\u00a0 Here\u2019s one for C#:<\/p>\n<pre><code>public static async void GetBuilds()\r\n{\r\n    try\r\n    {\r\n        var username = \"username\";\r\n        var password = \"password\";\r\n        using (HttpClient client = new HttpClient())\r\n        {\r\n            client.DefaultRequestHeaders.Accept.Add(\r\n                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(\"application\/json\"));\r\n            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(\"Basic\",\r\n                Convert.ToBase64String(\r\n                    System.Text.ASCIIEncoding.ASCII.GetBytes(\r\n                        string.Format(\"{0}:{1}\", username, password))));\r\n            using (HttpResponseMessage response = client.GetAsync(\r\n                        \"https:\/\/{account}.visualstudio.com\/DefaultCollection\/_apis\/build\/builds\").Result)\r\n            {\r\n                response.EnsureSuccessStatusCode();\r\n                string responseBody = await response.Content.ReadAsStringAsync();\r\n                Console.WriteLine(responseBody);\r\n            }\r\n        }\r\n    }\r\n    catch (Exception ex)\r\n    {\r\n        Console.WriteLine(ex.ToString());\r\n    }\r\n}<\/code><\/pre>\n<p>I\u2019ll give you a better example using OAuth to support integrated auth (rather then embedding credentials) as soon as I get the chance.<\/p>\n<p>If you want a \u201creal\u201d example, check out the source to our ZenDesk plugin on CodePlex: <a href=\"http:\/\/vsozendesk.codeplex.com\">http:\/\/vsozendesk.codeplex.com<\/a><\/p>\n<h2>Using Zapier to connect services<\/h2>\n<p>I also encourage you to check out <a href=\"http:\/\/zapier.com\">Zapier<\/a>.\u00a0 There are a number of similar services but I like this one.\u00a0 It makes it really easy to wire up Service hook event producers to consumers.\u00a0 It provides a very nice wizard that walks you through the process.\u00a0 You can visit the Visual Studio Online Zapier page here: <a title=\"https:\/\/zapier.com\/zapbook\/visual-studio-online\/\" href=\"https:\/\/zapier.com\/zapbook\/visual-studio-online\/\">https:\/\/zapier.com\/zapbook\/visual-studio-online\/<\/a> to learn more about hooking VS Online up and see the hundreds of service connections they enable.<\/p>\n<p>Here\u2019s some screen captures from the wizard to connect Visual Studio Online to Asana to show how easy it is.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/5545.image_thumb_74B843A0.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-15766\" src=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/5545.image_thumb_74B843A0.png\" alt=\"Image 5545 image thumb 74B843A0\" width=\"804\" height=\"294\" srcset=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/5545.image_thumb_74B843A0.png 804w, https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/5545.image_thumb_74B843A0-300x110.png 300w, https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/5545.image_thumb_74B843A0-768x281.png 768w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/6562.image_thumb_233674A3.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-15767\" src=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/6562.image_thumb_233674A3.png\" alt=\"Image 6562 image thumb 233674A3\" width=\"804\" height=\"664\" srcset=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/6562.image_thumb_233674A3.png 804w, https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/6562.image_thumb_233674A3-300x248.png 300w, https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/6562.image_thumb_233674A3-768x634.png 768w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/6557.image_thumb_26D72031.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-15768\" src=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/6557.image_thumb_26D72031.png\" alt=\"Image 6557 image thumb 26D72031\" width=\"804\" height=\"741\" srcset=\"https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/6557.image_thumb_26D72031.png 804w, https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/6557.image_thumb_26D72031-300x276.png 300w, https:\/\/devblogs.microsoft.com\/bharry\/wp-content\/uploads\/sites\/8\/2014\/05\/6557.image_thumb_26D72031-768x708.png 768w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Overall I\u2019m really excited about this new work.\u00a0 We\u2019ve been working hard on it for months and I encourage you to check it out.\u00a0 It\u2019s not nearly done.\u00a0 The REST APIs will evolve.\u00a0 The docs need work.\u00a0 We need more samples.\u00a0 Etc.\u00a0 But it\u2019s a very good start (IMHO) and I think you\u2019ll like it.\u00a0 Every sprint we\u2019ll be producing updates to make it better.\u00a0 Check it out and let us know what you think.<\/p>\n<p>Brian<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The \u201cbig\u201d news that I announced at TechEd this week was a new API for accessing Visual Studio Online (and, in a future release, Team Foundation Server).\u00a0 This new API is based on REST, OAUTH, Json and Service Hooks \u2013 all standard web technologies broadly supported in the industry.\u00a0 The API is still currently in [&hellip;]<\/p>\n","protected":false},"author":244,"featured_media":14617,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[8],"class_list":["post-1361","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-vsonline"],"acf":[],"blog_post_summary":"<p>The \u201cbig\u201d news that I announced at TechEd this week was a new API for accessing Visual Studio Online (and, in a future release, Team Foundation Server).\u00a0 This new API is based on REST, OAUTH, Json and Service Hooks \u2013 all standard web technologies broadly supported in the industry.\u00a0 The API is still currently in [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/posts\/1361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/users\/244"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/comments?post=1361"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/posts\/1361\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/media\/14617"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/media?parent=1361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/categories?post=1361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/bharry\/wp-json\/wp\/v2\/tags?post=1361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}