Learn Web API in 7 Days - The Ultimate Web API Tutorial
3.5 (59 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
14,041 students enrolled

Learn Web API in 7 Days - The Ultimate Web API Tutorial

Learn how to create cross platform web API services with advance topics like hosting, Unit Testing, Media Formats, Bson
3.5 (59 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
14,041 students enrolled
Created by Lalit Kumar
Last updated 1/2019
English
English [Auto-generated]
Current price: $11.99 Original price: $99.99 Discount: 88% off
2 days left at this price!
30-Day Money-Back Guarantee
This course includes
  • 2.5 hours on-demand video
  • 2 articles
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to Udemy's top 3,000+ courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Develop web api skills needed for api developer
  • Understanding of web api fundamentals

  • Create your own web api and consume

  • Versioning Web Api
  • Hosting web api with Owin
  • Using web api with https
  • Unit testing web api
  • Return csv, pdf or any custom format from api
Course content
Expand all 26 lectures 02:42:13
+ Introduction
6 lectures 28:59

What is ASP.NET Web API : ASP.NET Web APIs uses HTTP as its communication protocol. Since HTTP is light weight and flexible and it can be used by clients like browsers, mobile devices and even a desktop application. So it becomes a powerful platform for building APIs that expose Services and Data.

ASP.NET Web API is a framework for Creating web APIs on top of the .NET Framework.

Prerequisite for this lecture : You should know C#, and should be good in using Microsoft Visual Studio 2012/2013.

Software used in here are

  • Microsoft Visual Studio 2012/2013/2017

  • ASP.NET WEB API 2.0

  • Windows 8

Also you need to install WEB API project template if you are using Microsoft visual Studio 2012. You can do that by using nueget visual tool from extension manager, or u can use nueget console too

Preview 04:13

Dear students,

Before you start the course. Please take this quiz. To have an idea about where you stand on your way to learn ASP.Net Web API.

When you are done with the Quiz, Just note down your score. Later you can use this score to compare with score which you will get at the end of course. So revisit it at the end. All The best !!!

Before We begin Quiz
10 questions

What are the requirements to learn this course. Here is the list

Windows 10

Visual Studio 2012/2015/2017

Microsoft SQL Server Express.

IIS Express or IIS 6.0

Some knowledge of ASP.Net and How to use MS Visual Studio

Its good you know ASP.Net MVC

Basic Understanding of SQL Server Database

Although none of these are mandatory.

Basic Requirements For the Course
02:31

Installing SQL Server Express 2014

Go to Microsoft SQL Server Download Centre

Download SQL Server Express 2014

Install it.


Preview 04:12

In this video we learn how we can download and install Microsoft Visual Studio 2017. And also see how to use it.

Preview 04:29

This lecture will cover the following things

  1. Web API Introduction

  2. Why Web API ?

  3. What Problem it solve ?

  4. Best Web API usage

  5. Learning path

  6. Creating Simple WEB API Application with Visual Studio 2017

ASP.NET WEB API GETTING STARTED
12:35
+ Creating ASP.NET WEB API
5 lectures 01:00:50

      This lecture will teach you the basics of creating a web application with an ASP.NET Web API. The lecture uses Entity Framework as data layer.

   The example is going to show you how we can use entity frame work with ASP.NET Web API. Here we are going to have a database table called  "Person" in MS SQL Server database and the create a edmx file for Db table for mapping this table in C# as a class. This class in tern will be used to send information in the form of Json to the Web API client.

Here is very important thing to note : The entity that gets generated by edmx file should not be send across layers. The good practice in this regard is : we create a custom entity which we can be fill in from our Linq query and return this entity or entity collection to the client.

Prerequisite for this lecture :

  - You should know C#

  - Should be good in using Microsoft Visual Studio 2012/2013.

  - Also should have an idea of how SQL Server connection can be made with edmx file for Entity Framework.

- Having basic knowledge of JQuery

The following software are used in the tutorial

      - Web API 2.1

      - Visual Studio 2013 Update 2

      - Entity Framework 5

      - .NET 4.5, Jquery

      - Ms SQL EXPRESS 2008

CREATING AN ASP.NET WEB API SERVICE AND WITH API METHOD OVERLOADING
19:53

In this we are going to discuss CRUD operation with asp.net web api

Doing CRUD Using Web API applications

What do you mean by CRUD

Mapping CRUD operations with Web API Method Types

Create – Post

Read – Get

Update – Put

Delete - Delete

Preview 03:48

In this lecture you will lean how to do CRUD operations in an HTTP service using ASP.NET Web API. Here we are using a Kendo grid at UI side. You can use any other data control of similar nature.

Normal CRUD : C=Create, R=Read, U= Update, D=Delete

Web API CRUD Mappings : C=POST, R=GET, U=PUT, D=DELETE

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

- Also should have an idea of how SQL Server connection can be made with edmx file for Entity Framework.

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- Ms SQL Server 2008

If you are in IT for some time now, then you must be knowing that CRUD means Create, Read, Update, and Delete. These are the 4 basic DB operations. HTTP based services too follow this model.

In this lecture, we will create a very simple web API to manage a list of Persons.

The Operations (CRUD)

There are four HTTP methods (GET, PUT, POST, and DELETE) which we are going to be map to Db level CRUD operations.

- GET pules the data from a specified URI.

- PUT updates an entity at a specified URI. PUT can also be used to create a new resource at a specified URI. In this lecture, Web API we are not supprting creation using PUT.

- POST creates a new entity.

- DELETE deletes an entity at a specified URI.

Doing CRUD with ASP.NET WEB API
18:33

What is OData

The Open Data Protocol (OData) is a data access protocol built on core protocols like HTTP and commonly accepted methodologies like REST for the web.

What are OData Query Options

When we call api methods we can pass query strings to the api call to do various things on service side like

Filter

Oder

Skip

Top etc.

Preview 02:57

Supporting OData Query Options With ASP.NET WEB API

What are OData Query Options : OData Query Options are the parameters that client can send in API URI just like query string. These Parameters can be used for various purposes at service level.

OData defines parameters that can be send by client in the Web API URI, these parameters can be used to modify Odata Queries.

A very simple example can be sorting records in a collection based on a property of the collections entity class.

Say we have Person entity like this

Person {FirstName, LastName, DOB} and you want the person collection sorted on LastName.For this kind of implementation we can use $orderby option

There is another very good usage of OData Query Options : Suppose the client is not in a situation to have data paging in place. In this case we do server side/ Web API side data paging so that Web API does not pass too much data to the client. For this kind of implementation we can use $inlinecount option

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

- Also should have an idea of how SQL Server connection can be made with edmx file for Entity Framework.

- Having basic knowledge of JQuery

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- Ms SQL Server 2008

Possible OData Query Options:

- $orderby:Sorts the results.

- $expand:Expands related entities inline.

- $filter:Filters the results, based on a Boolean condition.

- $inlinecount:Tells the server to include the total count of matching entities in the response. (Useful for server-side paging.)

- $select:Selects which properties to include in the response.

- $skip:Skips the first n results.

- $top:Returns only the first n the results.

Example URI for sorting person collection on LastName :

http://localhost/api/Person/?$orderby=LastName

Supporting OData Query Options in ASP.NET WEB API
15:39

In this quiz there are 4 questions which are related to this section.

Please go through this quiz.

It will help you in understanding where is your learning curve going to.

Section 2 - Quiz
4 questions
+ ASP.NET Web API and Routing Actions
6 lectures 31:04

What is Web API Routing

Convention based routing

Attribute Routing

In the convention-based routing, Web API uses route templates to determine which controller and action method to execute.

At least one route template must be added into route table in order to handle various HTTP requests.

What is ASP.Net Web API Routing
03:40

This lecture will teach you how ASP.NET Web API routes HTTP requests to WEB API controllers.

If you are familiar with ASP.NET MVC, the is will be very easy for you to grasp this concept since Web API routing is very similar to MVC routing. The basic difference is that Web API uses the HTTP method, not the URI path, to select the action. You can also use MVC-style routing in Web API.

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

- Also should have an idea of how SQL Server connection can be made with edmx file for Entity Framework.

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- Ms SQL Server 2008

Here are some of variations that have been tried in this lecture vedio.

- Using Method name Starting with Get Keyword in the starting of method name like: GetAllPerson()

- Using [HttpGet] and Method name not starting with Get keyword like: FindPersons()

- Using [AcceptVerbs("GET", "HEAD")] and Method name not starting with Get keyword like: FindPersons()

- [HttpGet]

[ActionName("PersonList")] and Method name not starting with Get keyword like: FindPersons()

- [NonAction] To prevent the Method from being called by Action Attribute.

Routing in ASP.NET Web API
05:58

What is Web API Routing

  1. Convention based routing

  2. Attribute Routing

Web API version 2.1 defines a new type of Routing called attribute routing.

Attribute Routing defines routing by using Route Attribute

It gives more control upon web API URLs.

What ASP.Net Web API Attribute Routing
03:53

Routing determines how Web API matches its URI to a controller action. In Web API 2 there is supports for a new type of routing, which is called attribute routing.

As the name itself implies, attribute routing uses attributes to define routes. It gives us more control over the URIs in our web API. For example, we can easily construct URIs that describe hierarchies of resources.

In Earlier version of Web API style of routing is called convention-based routing, it is still supported. Now we can combine both of these techniques in the same WEB API project.

In this lecture we will learn how to enable attribute routing and will understand the various options for attribute routing.

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

- Also should have an idea of how SQL Server connection can be made with edmx file for Entity Framework.

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- Ms SQL Server 2008

Here are the benefits of Attribute routing.

API versioning

/api/v1/Products

/api/v2/Products

Overloaded URI segments

In this example, “10” is an order number, but “customers” maps to a collection.

/orders/10

/orders/customers

Multiple parameter types

In this example, “10” is an order number, but “2014/12/12” specifies a date.

/orders/customers/10

/orders/2014/12/12

Attribute Routing in ASP.NET Web API
07:59

What is Exception in General: Using Try catch and Finally blocks

What is Exception Handling in Web Api

Here are some of the possible exception handling classes that we can use in ASP.NET WEB API error management.

- HttpResponseException: The HttpResponseException type is a special case. This exception class returns any HTTP status code that you specify in the exception constructor

- Exception Filters: We can customize how a Web API Application can handles exceptions using an exception filter. An exception filter gets executed whenever a controller operation breaks and an un-handeled exception is thrown which is not an HttpResponseException exception.

What is Exception Handling
02:30

In this lecture we will cover ASP.NET WEB API exception handling mechanisms.

Here are some of the possible exception handling classes that we can use in ASP.NET WEB API error management.

- HttpResponseException: The HttpResponseException type is a special case. This exception class returns any HTTP status code that you specify in the exception constructor

- Exception Filters: We can customize how a Web API Application can handles exceptions using an exception filter. An exception filter gets executed whenever a controller operation breaks and an un-handeled exception is thrown which is not an HttpResponseException exception.

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

- Also should have an idea of how SQL Server connection can be made with edmx file for Entity Framework.

- Understanding try {} and Catch{} blocks

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- Ms SQL Server 2008

Registering Exception Filters

There are several ways to register a Web API exception filter:

- By action

- By controller

- Globally

- HttpError: The HttpError class provides a good way to catch and return errors and messages in the response body. Here you can see how to return HTTP status code 404 (Not Found) with HttpError in the response body.

public PersonEntity GetPerson(int id)

{

PersonEntity person = personManager.GetPersonById(id);

if (person == null)

{

var message = string.Format("Person with id = {0} not found", id);

throw new HttpResponseException(

Request.CreateErrorResponse(HttpStatusCode.NotFound, message));

}

else

{

return person;

}

}

ASP.NET Web API and Exception Handling
07:04

In this quiz there are 5 questions which are related to this section.

Please go through this quiz.

It will help you in understanding where is your learning curve going to.

Section 3 quiz
5 questions
+ ASP.NET WEB API Formats
3 lectures 17:21

By default ASP.NET Web API supports XML data format. To enable json data format we need to disable XML formatting in WebApiConfig like this:

config.Formatters.Remove(config.Formatters.XmlFormatter);

This true with other data formats also like bson, custom format

This lecture shows how to support additional media formats in ASP.NET Web API.

The type of media determines how ASP.NET Web API serializes and de-serializes the HTTP message body.

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

- Also should have an idea of how SQL Server connection can be made with edmx file for Entity Framework.

- JQuery

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- Ms SQL Server 2008

Web API has built-in support for the following data types

- XML

- JSON

- BSON

- Form-urlencoded data

Also we can support additional media types by writing our own custom media formatter.

To create a custom a media Formatter, we need to derive custom class from one of these two classes:

- MediaTypeFormatter: MediaTypeFormatter uses asynchronous read and write methods.

- BufferedMediaTypeFormatter: This class derives from MediaTypeFormatter and it uses synchronous read/write methods.

The following video shows a media type formatter that can serialize a Person collection object to a comma-separated values (CSV).

Media Formatters in ASP.NET WEB API
09:22

ASP.NET WEB API JSON Media-Type Formatter

JSON formatting is provided by the JsonMediaTypeFormatter class.

By default, JsonMediaTypeFormatter uses the Json.NET library to perform serialization. Json.NET is a third-party open source project.

ASP.NET WEB API XML Media Type Formatter

XML formatting is provided by the XmlMediaTypeFormatter class.

By default, XmlMediaTypeFormatter uses the DataContractSerializer class to perform serialization.

If you want, you can configure the XmlMediaTypeFormatter to use the XmlSerializer instead of the DataContractSerializer.

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

- Also should have an idea of how SQL Server connection can be made with edmx file for Entity Framework.

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- Ms SQL Server 2008

Removing the JSON or XML Formatter

You can remove the JSON formatter or the XML formatter from the list of formatters, if you do not want to use them. The main reasons to do this are:

To restrict your web API responses to a particular media type. For example, you might decide to support only JSON responses, and remove the XML formatter.

To replace the default formatter with a custom formatter. For example, you could replace the JSON formatter with your own custom implementation of a JSON formatter.

// Remove the JSON formatter

config.Formatters.Remove(config.Formatters.JsonFormatter);

// Remove the XML formatter

config.Formatters.Remove(config.Formatters.XmlFormatter);

JSON and XML Serialization in ASP.NET Web API
05:00

Why BSON?

BSON is a binary serialization format. “BSON” stands for “Binary JSON”, BSON and JSON are serialized in a very different manner. BSON is “JSON-like”, because objects are represented as name-value pairs, which very similar to JSON. but in BSON numeric data types are stored as bytes, not as strings

The BSON was designed to be lightweight, easy to scan, and fast to encode/decode.

BSON is comparable in size to JSON. Depending on the data, a BSON payload may be smaller or larger than a JSON payload. For serializing binary data, such as an image file, BSON is smaller than JSON, because the binary data does is not base64-encoded.

BSON documents are easy to scan because elements are prefixed with a length field, so a parser can skip elements without decoding them.

Encoding and decoding are efficient, because numeric data types are stored as numbers, not strings.

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

- Also should have an idea of how SQL Server connection can be made with edmx file for Entity Framework.

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- Ms SQL Server 2008

Enabling BSON on the Server

In your Web API configuration, add the BsonMediaTypeFormatter to the formatters collection.

// Enable Bson

config.Formatters.Add(new BsonMediaTypeFormatter());

var bson = new BsonMediaTypeFormatter();

bson.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/vnd.contoso"));

config.Formatters.Add(bson);

BSON Support in ASP.NET Web API 2.1
02:59

This quiz will help you in understanding how well you grasped concepts of this section.

Section 4 Quiz
6 questions
+ Testing and Debugging
1 lecture 05:27

Unit Testing ASP.NET Web API 2

Unit testing is one of the very important tasks in software development. Unit testing is generally carried out by developers itself.

Developers write and unit tests together.

Unit testing ASP.Net WEB API controllers is very simple. This process is very well described in the video of this lecture.

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

- Also should have an idea of how SQL Server connection can be made with edmx file for Entity Framework.

- Some background on how to create unit tests in Microsoft Visual Studio.

- In this lecture we assumes that you are familiar with the basic concepts of ASP.NET Web API.

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- MS SQL Server 2008

Unit Testing Controllers in ASP.NET Web API
05:27

This quiz will help getting better hold on the testing and debugging concepts.

Section 5 Quiz
3 questions
+ ASP.NET Web API Deployment And Hosting
2 lectures 05:38

Use OWIN to Self-Host ASP.NET Web API 2

In this lecture we will shows you how to SELF host ASP.NET Web API in a console application, using OWIN to self-host the Web API framework.

OWIN stands for (Open Web Interface for .NET) and it defines a kind of abstraction between .NET web servers and web applications.

OWIN main feature is to decouple the web application from the server, which makes OWIN ideal for self-hosting a web application in your own process, outside of IIS.

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- Ms SQL Server 2008

OWIN to Self-Host ASP.NET Web API
03:35

Hosting ASP.NET WEB API in IIS and IISEXPRESS.

If you are familiar with visual studio and IIS then for it will be really simple to host ASP.NET WEB API apps in IIS and IISExpress.

Prerequisite for this lecture :

- You should know C#

- Should be good in using Microsoft Visual Studio 2012/2013.

- Also should have an idea of how to use IIS Manager.

The following software are used in the tutorial

- Web API 2.1

- Visual Studio 2013 Update 2

- Entity Framework 6

- .NET 4.5

- Ms SQL Server 2008

- IISExpress, IIS

In this video you will see how we can are going to host a Web API in IIS 7.5 on Windows 8.

Hosting ASP.NET Web API in IIS and IISExpress
02:03
Section 6 Quiz
4 questions
+ Advance Topics
3 lectures 13:19

While developing ASP.Net web API, there can be a requirement  to have some of the end points of web API running on http and some on https. In this lecture you will see how to achieve that.

To enable https in ASP.Net web api we need to do the following things.

- Create a custom https filter class

- Register that filter class in web api configuration

- Add [RequireHttps] attribute to api controller methods where we need https communication

- enable https support on local development server.

- Create and install a certificate on you local machine for SSL to work.

All of this is explained in  this video.

How To Enable Https in ASP.Net Web API
08:10
Https and Web API
02:43
Working with OData query options
02:26
+ Learning Evaluation
0 lectures 00:00

You can take this Quiz at the end of course. After completion just note down your score.

Also add up scores of all the prev quizzes except the first one(Before we begin). Before we begin Quiz score will not be added to final score.

Here is how you can sum up your score.

Give 2.5 marks to each True/False correct question And give 3.5 marks to each multiple choice correct question.

Here are Grades that you will get once you have your scores.

A + = 90 - 100, A = 80 - 89, B+ = 60 - 79, B = 50 - 59

C= 40- 49, Below 40 Fail

Learning Evaluation Quiz
12 questions
Requirements
  • Aspiring It professionals having some background in .Net development and want to learn asp net web api
  • Experienced Developers looking to enhance their knowledge of web API development
Description

Asp dot net web api is a dot net framework which is part of Asp dot Net MVC 4. In this web api course, you can master Asp net web api restful service development in few days only.

Here is the list of lectures which are part of this course. 

Lecture 1: Getting Started with ASP dot net Web API 

Lecture 2: Using ASP dot net Web API with Microsoft Entity Framework 

Lecture 3: Supporting OData Query Options in ASP dot net Web API 

Lecture 4: Doing CRUD with ASP dot net Web API 

Lecture 5: Routing in ASP dot net Web API 

Lecture 6: Attribute Routing in ASP dot net Web API 

Lecture 7: ASP dot net Web API and Exception Handling 

Lecture 8: Media Formatters in ASP dot net Web API 

Lecture 9: JSON and XML Serialization in ASP dot net Web API 

Lecture 10: BSON Support in ASP dot net Web API 2.1 

Lecture 11: Unit Testing Controllers in ASP dot net Web API 

Lecture 12: OWIN to Self-Host ASP dot net Web API 

Lecture 13: Hosting ASP dot net Web API in IIS & IISExpress 

And More...

Who can attend this course? 

The course is designed for .Net Developers, Tech Leads and Architects who are working on Microsoft technologies like ASP dot net, ASP dot net MVC for developing web and mobile based applications and they want to learn web api

Prerequisites 

You will need Visual Studio 2012/13/2015/2017 and ASP MS SQL Express to do practical’s as stated here. The course is mainly covered as videos and presentations. 

Course Duration 

It depends on the individual pace to complete the course. This asp net web api course is targeted to finish in a week. 

What will you be learning 

After completion the learner will be able to develop ASP dot net Web API services comfortably. 

Who this course is for:
  • Freshers who want to learn web api
  • .Net Developers interested in learning asp net web api
  • IT Professionals looking for career growth and want to learn web api