In this tutorial I will show you how easy it is to consume a REST API Service using the ‘Service Reference …’ feature in Visual Studio 2019. I will consume a simple service located at https://api4all.azurewebsites.net/.
Companion video: https://youtu.be/XqIniGHpcEc
Source Code: https://github.com/medhatelmasry/ConsumeOpenAPI.git
- You need to have Visual Studio 2019 installed on your Windows computer. In my case, I am using: Microsoft Visual Studio Community 2019 Version 16.8.2
- The REST API you are consuming needs to have an OpenAPI programming language-agnostic interface description for REST APIs.
|Method name||HTTP Verb||Purpose|
|StudentsAllAsync||GET||retrieve all students|
|Students2Async||GET||get student by id|
|StudentsAsync||POST||add a student|
|Students3Async||PUT||update student data|
|Students4Async||DELETE||delete student by id|