Web API Basics




     Learn More @ http://www.learnnowonline.com
        Copyright © by Application Developers Training Company
Objectives




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Objectives
• See how REST and web services can be
  used to access data




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Objectives
• See how REST and web services can be
  used to access data
• Build your first Web API service




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Objectives
• See how REST and web services can be
  used to access data
• Build your first Web API service
• Use Web API naming conventions for
  routing




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Objectives
• See how REST and web services can be
  used to access data
• Build your first Web API service
• Use Web API naming conventions for
  routing
• Modify your service for basic CRUD
  operations


         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda




     Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service
• Web API Routing




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
•   What Is ASP.NET Web API?
•   Create Your First Web API Service
•   Web API Routing
•   Create a Web API Service for CRUD
    Operations




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service
• Web API Routing
• Create a Web API Service for CRUD
  Operations
• Filtering Data with Parameters



         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
What Is ASP.NET Web API?




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
What Is ASP.NET Web API?
• Next iteration of WCF REST




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
What Is ASP.NET Web API?
• Next iteration of WCF REST
• Incorporated into ASP.NET MVC 4




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
What Is ASP.NET Web API?
• Next iteration of WCF REST
• Incorporated into ASP.NET MVC 4
• Framework for developing REST
  oriented services




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
REST




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
REST
• Uses HTTP protocols




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
REST
• Uses HTTP protocols
• URLs and methods




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
REST
• Uses HTTP protocols
• URLs and methods
• Accessible from a wide variety of
  clients




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
REST
• Uses HTTP protocols
• URLs and methods
• Accessible from a wide variety of
  clients
• HTTP methods:




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
REST
• Uses HTTP protocols
• URLs and methods
• Accessible from a wide variety of
  clients
• HTTP methods:
  • GET




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
REST
• Uses HTTP protocols
• URLs and methods
• Accessible from a wide variety of
  clients
• HTTP methods:
  • GET
  • POST



           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
REST
• Uses HTTP protocols
• URLs and methods
• Accessible from a wide variety of
  clients
• HTTP methods:
  • GET
  • POST
  • PUT


           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
GET




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
GET
• Primarily just a URL making a simple
  request for a resource, e.g., a web page




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
GET
• Primarily just a URL making a simple
  request for a resource, e.g., a web page
• Response is sent back




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
GET
• Primarily just a URL making a simple
  request for a resource, e.g., a web page
• Response is sent back
• Additional information is put in a query
  string




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
GET
• Primarily just a URL making a simple
  request for a resource, e.g., a web page
• Response is sent back
• Additional information is put in a query
  string
• Generally used to Select data




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
GET
• Primarily just a URL making a simple
  request for a resource, e.g., a web page
• Response is sent back
• Additional information is put in a query
  string
• Generally used to Select data
• Selecting all:




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
GET
• Primarily just a URL making a simple
  request for a resource, e.g., a web page
• Response is sent back
• Additional information is put in a query
  string
• Generally used to Select data
• Selecting all:
http://www.root.com/products/



          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
GET
• Primarily just a URL making a simple
  request for a resource, e.g., a web page
• Response is sent back
• Additional information is put in a query
  string
• Generally used to Select data
• Selecting all:
http://www.root.com/products/
• Selecting one:

          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
POST




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
POST
• Sends collection of name-value pairs
  along with the request




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
POST
• Sends collection of name-value pairs
  along with the request
• Commonly used with forms on the web




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
POST
• Sends collection of name-value pairs
  along with the request
• Commonly used with forms on the web
• Used to add new resources (Insert)




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
POST
• Sends collection of name-value pairs
  along with the request
• Commonly used with forms on the web
• Used to add new resources (Insert)
• Should return an appropriate HTTP
  success code



         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
PUT




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
PUT
• Used to store a resource at the
  supplied URL




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
PUT
• Used to store a resource at the
  supplied URL
• Generally used for Editing existing
  resources




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
DELETE




     Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
DELETE
• Used for deleting resources




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
DELETE
• Used for deleting resources
• Should return an appropriate HTTP
  code




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda




     Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service
• Web API Routing




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
•   What Is ASP.NET Web API?
•   Create Your First Web API Service
•   Web API Routing
•   Create a Web API Service for CRUD
    Operations




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service
• Web API Routing
• Create a Web API Service for CRUD
  Operations
• Filtering Data with Parameters



         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Create Your First Web API




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Create Your First Web API
 • Create a repository




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Create Your First Web API
 • Create a repository
 • Create an API controller to use the
   repository




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Create Your First Web API
 • Create a repository
 • Create an API controller to use the
   repository
 • Try it out in a browser




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Agenda




     Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service
• Web API Routing




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
•   What Is ASP.NET Web API?
•   Create Your First Web API Service
•   Web API Routing
•   Create a Web API Service for CRUD
    Operations




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service
• Web API Routing
• Create a Web API Service for CRUD
  Operations
• Filtering Data with Parameters



         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Web API Routing




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Web API Routing
• Interpretation of URLs by the server to
  decide what code should handle the
  request




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Web API Routing
• Interpretation of URLs by the server to
  decide what code should handle the
  request
• Operates similarly to ASP.NET MVC
  routing




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Web API Routing
• Interpretation of URLs by the server to
  decide what code should handle the
  request
• Operates similarly to ASP.NET MVC
  routing
• Actions determined by HTTP method
  used


          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Default Mapping




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Default Mapping
• Configured in Global.asax




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Default Mapping
• Configured in Global.asax
• Uses “api” as URL segment




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Default Mapping
• Configured in Global.asax
• Uses “api” as URL segment
• Adds word “Controller” to the
  controller part of URL




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Default Mapping
• Configured in Global.asax
• Uses “api” as URL segment
• Adds word “Controller” to the
  controller part of URL
• Looks for action that begins with the
  HTTP method



         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Default Mapping
• Configured in Global.asax
• Uses “api” as URL segment
• Adds word “Controller” to the
  controller part of URL
• Looks for action that begins with the
  HTTP method
• Additional URL parameters are mapped
  as action parameters

         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Alternative Routing




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Alternative Routing
• Rarely necessary for most Web API
  services




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Alternative Routing
• Rarely necessary for most Web API
  services
• Several options to change URL routing




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
HTTP Method Attributes




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
HTTP Method Attributes
• Very similar to ASP.NET MVC




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
HTTP Method Attributes
• Very similar to ASP.NET MVC
• Use attributes to bind HTTP methods
  to specific actions




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
HTTP Method Attributes
• Very similar to ASP.NET MVC
• Use attributes to bind HTTP methods
  to specific actions
[HttpGet]




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
HTTP Method Attributes
• Very similar to ASP.NET MVC
• Use attributes to bind HTTP methods
  to specific actions
[HttpGet]
[HttpPost]




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
HTTP Method Attributes
• Very similar to ASP.NET MVC
• Use attributes to bind HTTP methods
  to specific actions
[HttpGet]
[HttpPost]
[HttpPut]



         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
HTTP Method Attributes
• Very similar to ASP.NET MVC
• Use attributes to bind HTTP methods
  to specific actions
[HttpGet]
[HttpPost]
[HttpPut]
[HttpDelete]

         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
AcceptVerbs Attribute




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
AcceptVerbs Attribute
• Also used on actions




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
AcceptVerbs Attribute
• Also used on actions
• Specify HTTP methods as strings




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
AcceptVerbs Attribute
• Also used on actions
• Specify HTTP methods as strings
• Especially useful for atypical HTTP
  methods




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Action Names in the URL




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Action Names in the URL
• Makes URLs route identically to
  ASP.NET MVC




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Action Names in the URL
• Makes URLs route identically to
  ASP.NET MVC
• Must change routeTemplate in
  Global.asax




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Action Names in the URL
• Makes URLs route identically to
  ASP.NET MVC
• Must change routeTemplate in
  Global.asax
• Must also add HTTP method attributes
  to actions



         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Removing Actions from




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Removing Actions from
• Used when a resource’s URL would
  trigger an action, but this is not
  desired




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Removing Actions from
• Used when a resource’s URL would
  trigger an action, but this is not
  desired
• Use the NonAction attribute on the
  method




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda




     Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service
• Web API Routing




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
•   What Is ASP.NET Web API?
•   Create Your First Web API Service
•   Web API Routing
•   Create a Web API Service for CRUD
    Operations




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service
• Web API Routing
• Create a Web API Service for CRUD
  Operations
• Filtering Data with Parameters



        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Create a Web API Service for
CRUD Operations




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Create a Web API Service for
CRUD Operations

• Create – POST




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Create a Web API Service for
CRUD Operations

• Create – POST
• Read – GET




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Create a Web API Service for
CRUD Operations

• Create – POST
• Read – GET
• Update – PUT




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Create a Web API Service for
CRUD Operations

•   Create – POST
•   Read – GET
•   Update – PUT
•   Delete – DELETE




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Create a Web API Service for
CRUD Operations

•   Create – POST
•   Read – GET
•   Update – PUT
•   Delete – DELETE
•   Basic functionality that most services
    will have


           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Create a Web API Service for
CRUD Operations

• Create – POST
• Read – GET
• Update – PUT
• Delete – DELETE
• Basic functionality that most services
  will have
• Try it out!
        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Agenda




     Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service
• Web API Routing




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
•   What Is ASP.NET Web API?
•   Create Your First Web API Service
•   Web API Routing
•   Create a Web API Service for CRUD
    Operations




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Agenda
• What Is ASP.NET Web API?
• Create Your First Web API Service
• Web API Routing
• Create a Web API Service for CRUD
  Operations
• Filtering Data with Parameters



         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Filtering Data with




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Filtering Data with
• Uses the OData protocol




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Filtering Data with
• Uses the OData protocol
• Special query strings can be used to:




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Filtering Data with
• Uses the OData protocol
• Special query strings can be used to:
  • Filter




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Filtering Data with
• Uses the OData protocol
• Special query strings can be used to:
  • Filter
  • Page




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Filtering Data with
• Uses the OData protocol
• Special query strings can be used to:
  • Filter
  • Page
  • Sort




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Filtering Data with
• Uses the OData protocol
• Special query strings can be used to:
  • Filter
  • Page
  • Sort
  • And more…




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Filter




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Filter
• Condition that evaluates to true or
  false




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Filter
• Condition that evaluates to true or
  false
• Uses OData-specific keywords




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Filter
• Condition that evaluates to true or
  false
• Uses OData-specific keywords
• Must be sendable in a URL




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Order By




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Order By
• Specifies the sort order of returned
  data




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Order By
• Specifies the sort order of returned
  data
• Can sort by multiple properties




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Order By
• Specifies the sort order of returned
  data
• Can sort by multiple properties
• Can specify ASC and DESC sorting




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Paging




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Paging
• Done by using $skip and $top




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Paging
• Done by using $skip and $top
• $skip passes over a number of records




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Paging
• Done by using $skip and $top
• $skip passes over a number of records
• $skip should be set to: page number *
  page size




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Paging
• Done by using $skip and $top
• $skip passes over a number of records
• $skip should be set to: page number *
  page size
• $top selects a certain number to return




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Paging
• Done by using $skip and $top
• $skip passes over a number of records
• $skip should be set to: page number *
  page size
• $top selects a certain number to return
• $top should be set to page size



         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
There’s More




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
There’s More
• There are other OData query strings




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
There’s More
• There are other OData query strings
• Other query keywords for $filter




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
There’s More
• There are other OData query strings
• Other query keywords for $filter
• www.odata.org




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Learn More!




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company

More Related Content

PPTX
Understanding REST APIs in 5 Simple Steps
PDF
REST API and CRUD
PPTX
Restful api
PPTX
An Introduction To REST API
PPTX
PDF
What is REST API? REST API Concepts and Examples | Edureka
PPTX
Introduction to Spring Boot
PPTX
REST API Design & Development
Understanding REST APIs in 5 Simple Steps
REST API and CRUD
Restful api
An Introduction To REST API
What is REST API? REST API Concepts and Examples | Edureka
Introduction to Spring Boot
REST API Design & Development

What's hot (20)

PDF
Api presentation
PPTX
[Final] ReactJS presentation
PPTX
Intro to React
PPTX
Soap web service
PPTX
React js programming concept
PPTX
ASP.NET Web API
PPTX
Introduction to REST - API
PDF
React & GraphQL
PPT
Understanding REST
PDF
React js
PPT
Introduction to the Web API
PDF
Clean architectures with fast api pycones
PPTX
React JS part 1
PPTX
Introduction to React JS
PDF
Rest API Automation with REST Assured
PPTX
React workshop presentation
PPSX
Rest api standards and best practices
PPTX
Flask – Python
PPTX
Spring boot Introduction
Api presentation
[Final] ReactJS presentation
Intro to React
Soap web service
React js programming concept
ASP.NET Web API
Introduction to REST - API
React & GraphQL
Understanding REST
React js
Introduction to the Web API
Clean architectures with fast api pycones
React JS part 1
Introduction to React JS
Rest API Automation with REST Assured
React workshop presentation
Rest api standards and best practices
Flask – Python
Spring boot Introduction
Ad

Viewers also liked (18)

PDF
Enterprise Use Case Webinar – Development Governance with the WSO2 Governance...
PDF
Multi Tenant API management with WSO2 API Manager
PDF
Customizing the API Store & Publisher in WSO2 API Manager
PDF
Introduction to g reg 4.6.0
PPTX
API Management Workshop (at Startupbootcamp Berlin)
PPT
API 101 - Understanding APIs
PDF
An Introduction to the WSO2 API Manager
PPTX
API designing with WSO2 API Manager
PPTX
WSO2 Identity Server 5.3.0 - Product Release Webinar
PDF
WSO2Con USA 2017: Implementing a Modern API Management Solution that Benefits...
PPTX
ASP.NET Web API and HTTP Fundamentals
PDF
C# ASP.NET WEB API APPLICATION DEVELOPMENT
PDF
WSO2Con USA 2017: Iterative Architecture: A Pragmatic Approach to Digital Tra...
PDF
WSO2Con USA 2017: Rise to the Challenge with WSO2 Identity Server and WSO2 AP...
PPTX
WSO2Con USA 2017: DevOps Best Practices in 7 Steps
PDF
Best Practices for API Management
PDF
WSO2Con USA 2017: Managing Verifone’s New Payment Device “Carbon” with WSO2’s...
PPT
API Management architect presentation
Enterprise Use Case Webinar – Development Governance with the WSO2 Governance...
Multi Tenant API management with WSO2 API Manager
Customizing the API Store & Publisher in WSO2 API Manager
Introduction to g reg 4.6.0
API Management Workshop (at Startupbootcamp Berlin)
API 101 - Understanding APIs
An Introduction to the WSO2 API Manager
API designing with WSO2 API Manager
WSO2 Identity Server 5.3.0 - Product Release Webinar
WSO2Con USA 2017: Implementing a Modern API Management Solution that Benefits...
ASP.NET Web API and HTTP Fundamentals
C# ASP.NET WEB API APPLICATION DEVELOPMENT
WSO2Con USA 2017: Iterative Architecture: A Pragmatic Approach to Digital Tra...
WSO2Con USA 2017: Rise to the Challenge with WSO2 Identity Server and WSO2 AP...
WSO2Con USA 2017: DevOps Best Practices in 7 Steps
Best Practices for API Management
WSO2Con USA 2017: Managing Verifone’s New Payment Device “Carbon” with WSO2’s...
API Management architect presentation
Ad

Similar to Web API Basics (20)

KEY
Web API HTTP Pipeline
KEY
Managing site collections
KEY
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
KEY
SharePoint Document Management
KEY
Asynchronous Programming
KEY
What's new in Silverlight 5
KEY
Introduction to ASP.NET MVC
KEY
SharePoint: Introduction to InfoPath
KEY
KnockOutJS with ASP.NET MVC
KEY
Object-Oriented JavaScript
KEY
Using The .NET Framework
KEY
Bring a Web Page Alive with jQuery
KEY
Introducing LINQ
KEY
WPF Binding
PDF
Создание API, которое полюбят разработчики. Глубокое погружение
KEY
.NET Variables and Data Types
KEY
SQL Server: Security
KEY
Working with Controllers and Actions in MVC
PPT
New in the Visual Studio 2012 IDE
KEY
The Entity Data Model
Web API HTTP Pipeline
Managing site collections
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
SharePoint Document Management
Asynchronous Programming
What's new in Silverlight 5
Introduction to ASP.NET MVC
SharePoint: Introduction to InfoPath
KnockOutJS with ASP.NET MVC
Object-Oriented JavaScript
Using The .NET Framework
Bring a Web Page Alive with jQuery
Introducing LINQ
WPF Binding
Создание API, которое полюбят разработчики. Глубокое погружение
.NET Variables and Data Types
SQL Server: Security
Working with Controllers and Actions in MVC
New in the Visual Studio 2012 IDE
The Entity Data Model

More from LearnNowOnline (12)

PPT
Windows 8: Shapes and Geometries
PPT
SQL: Permissions and Data Protection
KEY
Attributes, reflection, and dynamic programming
KEY
WPF: Working with Data
KEY
A tour of SQL Server
KEY
Generics
KEY
Object oriented techniques
KEY
Sql 2012 development and programming
KEY
Expression Blend Motion & Interaction Design
KEY
Introducing the Entity Framework
KEY
Creating a User Interface
KEY
.Net branching and flow control
Windows 8: Shapes and Geometries
SQL: Permissions and Data Protection
Attributes, reflection, and dynamic programming
WPF: Working with Data
A tour of SQL Server
Generics
Object oriented techniques
Sql 2012 development and programming
Expression Blend Motion & Interaction Design
Introducing the Entity Framework
Creating a User Interface
.Net branching and flow control

Recently uploaded (20)

PDF
The Digital Engine Room: Unlocking APAC’s Economic and Digital Potential thro...
PPTX
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
PDF
NewMind AI Journal Monthly Chronicles - August 2025
PDF
1_Keynote_Breaking Barriers_한계를 넘어서_Charith Mendis.pdf
PDF
State of AI in Business 2025 - MIT NANDA
PDF
Applying Agentic AI in Enterprise Automation
PDF
Uncertainty-aware contextual multi-armed bandits for recommendations in e-com...
PPTX
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
PDF
Altius execution marketplace concept.pdf
PDF
eBook Outline_ AI in Cybersecurity – The Future of Digital Defense.pdf
PDF
Peak of Data & AI Encore: Scalable Design & Infrastructure
PPTX
CRM(Customer Relationship Managmnet) Presentation
PDF
The Basics of Artificial Intelligence - Understanding the Key Concepts and Te...
PDF
Gestión Unificada de los Riegos Externos
PDF
ment.tech-How to Develop an AI Agent Healthcare App like Sully AI (1).pdf
PDF
TicketRoot: Event Tech Solutions Deck 2025
PDF
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
PDF
Decision Optimization - From Theory to Practice
PPT
Overviiew on Intellectual property right
The Digital Engine Room: Unlocking APAC’s Economic and Digital Potential thro...
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
NewMind AI Journal Monthly Chronicles - August 2025
1_Keynote_Breaking Barriers_한계를 넘어서_Charith Mendis.pdf
State of AI in Business 2025 - MIT NANDA
Applying Agentic AI in Enterprise Automation
Uncertainty-aware contextual multi-armed bandits for recommendations in e-com...
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
Altius execution marketplace concept.pdf
eBook Outline_ AI in Cybersecurity – The Future of Digital Defense.pdf
Peak of Data & AI Encore: Scalable Design & Infrastructure
CRM(Customer Relationship Managmnet) Presentation
The Basics of Artificial Intelligence - Understanding the Key Concepts and Te...
Gestión Unificada de los Riegos Externos
ment.tech-How to Develop an AI Agent Healthcare App like Sully AI (1).pdf
TicketRoot: Event Tech Solutions Deck 2025
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
Decision Optimization - From Theory to Practice
Overviiew on Intellectual property right

Web API Basics

  • 1. Web API Basics Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 2. Objectives Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 3. Objectives • See how REST and web services can be used to access data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 4. Objectives • See how REST and web services can be used to access data • Build your first Web API service Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 5. Objectives • See how REST and web services can be used to access data • Build your first Web API service • Use Web API naming conventions for routing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 6. Objectives • See how REST and web services can be used to access data • Build your first Web API service • Use Web API naming conventions for routing • Modify your service for basic CRUD operations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 7. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 8. Agenda • What Is ASP.NET Web API? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 9. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 10. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 11. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing • Create a Web API Service for CRUD Operations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 12. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing • Create a Web API Service for CRUD Operations • Filtering Data with Parameters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 13. What Is ASP.NET Web API? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 14. What Is ASP.NET Web API? • Next iteration of WCF REST Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 15. What Is ASP.NET Web API? • Next iteration of WCF REST • Incorporated into ASP.NET MVC 4 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 16. What Is ASP.NET Web API? • Next iteration of WCF REST • Incorporated into ASP.NET MVC 4 • Framework for developing REST oriented services Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 17. REST Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 18. REST • Uses HTTP protocols Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 19. REST • Uses HTTP protocols • URLs and methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 20. REST • Uses HTTP protocols • URLs and methods • Accessible from a wide variety of clients Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 21. REST • Uses HTTP protocols • URLs and methods • Accessible from a wide variety of clients • HTTP methods: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 22. REST • Uses HTTP protocols • URLs and methods • Accessible from a wide variety of clients • HTTP methods: • GET Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 23. REST • Uses HTTP protocols • URLs and methods • Accessible from a wide variety of clients • HTTP methods: • GET • POST Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 24. REST • Uses HTTP protocols • URLs and methods • Accessible from a wide variety of clients • HTTP methods: • GET • POST • PUT Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 25. GET Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 26. GET • Primarily just a URL making a simple request for a resource, e.g., a web page Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 27. GET • Primarily just a URL making a simple request for a resource, e.g., a web page • Response is sent back Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 28. GET • Primarily just a URL making a simple request for a resource, e.g., a web page • Response is sent back • Additional information is put in a query string Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 29. GET • Primarily just a URL making a simple request for a resource, e.g., a web page • Response is sent back • Additional information is put in a query string • Generally used to Select data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 30. GET • Primarily just a URL making a simple request for a resource, e.g., a web page • Response is sent back • Additional information is put in a query string • Generally used to Select data • Selecting all: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 31. GET • Primarily just a URL making a simple request for a resource, e.g., a web page • Response is sent back • Additional information is put in a query string • Generally used to Select data • Selecting all: http://www.root.com/products/ Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 32. GET • Primarily just a URL making a simple request for a resource, e.g., a web page • Response is sent back • Additional information is put in a query string • Generally used to Select data • Selecting all: http://www.root.com/products/ • Selecting one: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 33. POST Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 34. POST • Sends collection of name-value pairs along with the request Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 35. POST • Sends collection of name-value pairs along with the request • Commonly used with forms on the web Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 36. POST • Sends collection of name-value pairs along with the request • Commonly used with forms on the web • Used to add new resources (Insert) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 37. POST • Sends collection of name-value pairs along with the request • Commonly used with forms on the web • Used to add new resources (Insert) • Should return an appropriate HTTP success code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 38. PUT Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 39. PUT • Used to store a resource at the supplied URL Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 40. PUT • Used to store a resource at the supplied URL • Generally used for Editing existing resources Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 41. DELETE Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 42. DELETE • Used for deleting resources Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 43. DELETE • Used for deleting resources • Should return an appropriate HTTP code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 44. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 45. Agenda • What Is ASP.NET Web API? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 46. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 47. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 48. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing • Create a Web API Service for CRUD Operations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 49. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing • Create a Web API Service for CRUD Operations • Filtering Data with Parameters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 50. Create Your First Web API Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 51. Create Your First Web API • Create a repository Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 52. Create Your First Web API • Create a repository • Create an API controller to use the repository Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 53. Create Your First Web API • Create a repository • Create an API controller to use the repository • Try it out in a browser Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 54. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 55. Agenda • What Is ASP.NET Web API? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 56. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 57. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 58. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing • Create a Web API Service for CRUD Operations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 59. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing • Create a Web API Service for CRUD Operations • Filtering Data with Parameters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 60. Web API Routing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 61. Web API Routing • Interpretation of URLs by the server to decide what code should handle the request Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 62. Web API Routing • Interpretation of URLs by the server to decide what code should handle the request • Operates similarly to ASP.NET MVC routing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 63. Web API Routing • Interpretation of URLs by the server to decide what code should handle the request • Operates similarly to ASP.NET MVC routing • Actions determined by HTTP method used Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 64. Default Mapping Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 65. Default Mapping • Configured in Global.asax Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 66. Default Mapping • Configured in Global.asax • Uses “api” as URL segment Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 67. Default Mapping • Configured in Global.asax • Uses “api” as URL segment • Adds word “Controller” to the controller part of URL Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 68. Default Mapping • Configured in Global.asax • Uses “api” as URL segment • Adds word “Controller” to the controller part of URL • Looks for action that begins with the HTTP method Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 69. Default Mapping • Configured in Global.asax • Uses “api” as URL segment • Adds word “Controller” to the controller part of URL • Looks for action that begins with the HTTP method • Additional URL parameters are mapped as action parameters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 70. Alternative Routing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 71. Alternative Routing • Rarely necessary for most Web API services Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 72. Alternative Routing • Rarely necessary for most Web API services • Several options to change URL routing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 73. HTTP Method Attributes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 74. HTTP Method Attributes • Very similar to ASP.NET MVC Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 75. HTTP Method Attributes • Very similar to ASP.NET MVC • Use attributes to bind HTTP methods to specific actions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 76. HTTP Method Attributes • Very similar to ASP.NET MVC • Use attributes to bind HTTP methods to specific actions [HttpGet] Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 77. HTTP Method Attributes • Very similar to ASP.NET MVC • Use attributes to bind HTTP methods to specific actions [HttpGet] [HttpPost] Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 78. HTTP Method Attributes • Very similar to ASP.NET MVC • Use attributes to bind HTTP methods to specific actions [HttpGet] [HttpPost] [HttpPut] Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 79. HTTP Method Attributes • Very similar to ASP.NET MVC • Use attributes to bind HTTP methods to specific actions [HttpGet] [HttpPost] [HttpPut] [HttpDelete] Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 80. AcceptVerbs Attribute Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 81. AcceptVerbs Attribute • Also used on actions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 82. AcceptVerbs Attribute • Also used on actions • Specify HTTP methods as strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 83. AcceptVerbs Attribute • Also used on actions • Specify HTTP methods as strings • Especially useful for atypical HTTP methods Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 84. Action Names in the URL Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 85. Action Names in the URL • Makes URLs route identically to ASP.NET MVC Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 86. Action Names in the URL • Makes URLs route identically to ASP.NET MVC • Must change routeTemplate in Global.asax Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 87. Action Names in the URL • Makes URLs route identically to ASP.NET MVC • Must change routeTemplate in Global.asax • Must also add HTTP method attributes to actions Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 88. Removing Actions from Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 89. Removing Actions from • Used when a resource’s URL would trigger an action, but this is not desired Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 90. Removing Actions from • Used when a resource’s URL would trigger an action, but this is not desired • Use the NonAction attribute on the method Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 91. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 92. Agenda • What Is ASP.NET Web API? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 93. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 94. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 95. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing • Create a Web API Service for CRUD Operations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 96. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing • Create a Web API Service for CRUD Operations • Filtering Data with Parameters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 97. Create a Web API Service for CRUD Operations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 98. Create a Web API Service for CRUD Operations • Create – POST Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 99. Create a Web API Service for CRUD Operations • Create – POST • Read – GET Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 100. Create a Web API Service for CRUD Operations • Create – POST • Read – GET • Update – PUT Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 101. Create a Web API Service for CRUD Operations • Create – POST • Read – GET • Update – PUT • Delete – DELETE Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 102. Create a Web API Service for CRUD Operations • Create – POST • Read – GET • Update – PUT • Delete – DELETE • Basic functionality that most services will have Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 103. Create a Web API Service for CRUD Operations • Create – POST • Read – GET • Update – PUT • Delete – DELETE • Basic functionality that most services will have • Try it out! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 104. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 105. Agenda • What Is ASP.NET Web API? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 106. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 107. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 108. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing • Create a Web API Service for CRUD Operations Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 109. Agenda • What Is ASP.NET Web API? • Create Your First Web API Service • Web API Routing • Create a Web API Service for CRUD Operations • Filtering Data with Parameters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 110. Filtering Data with Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 111. Filtering Data with • Uses the OData protocol Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 112. Filtering Data with • Uses the OData protocol • Special query strings can be used to: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 113. Filtering Data with • Uses the OData protocol • Special query strings can be used to: • Filter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 114. Filtering Data with • Uses the OData protocol • Special query strings can be used to: • Filter • Page Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 115. Filtering Data with • Uses the OData protocol • Special query strings can be used to: • Filter • Page • Sort Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 116. Filtering Data with • Uses the OData protocol • Special query strings can be used to: • Filter • Page • Sort • And more… Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 117. Filter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 118. Filter • Condition that evaluates to true or false Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 119. Filter • Condition that evaluates to true or false • Uses OData-specific keywords Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 120. Filter • Condition that evaluates to true or false • Uses OData-specific keywords • Must be sendable in a URL Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 121. Order By Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 122. Order By • Specifies the sort order of returned data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 123. Order By • Specifies the sort order of returned data • Can sort by multiple properties Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 124. Order By • Specifies the sort order of returned data • Can sort by multiple properties • Can specify ASC and DESC sorting Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 125. Paging Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 126. Paging • Done by using $skip and $top Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 127. Paging • Done by using $skip and $top • $skip passes over a number of records Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 128. Paging • Done by using $skip and $top • $skip passes over a number of records • $skip should be set to: page number * page size Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 129. Paging • Done by using $skip and $top • $skip passes over a number of records • $skip should be set to: page number * page size • $top selects a certain number to return Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 130. Paging • Done by using $skip and $top • $skip passes over a number of records • $skip should be set to: page number * page size • $top selects a certain number to return • $top should be set to page size Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 131. There’s More Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 132. There’s More • There are other OData query strings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 133. There’s More • There are other OData query strings • Other query keywords for $filter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 134. There’s More • There are other OData query strings • Other query keywords for $filter • www.odata.org Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 135. Learn More! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 136. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company

Editor's Notes