SlideShare a Scribd company logo
Will be an
introduction to
Web API
SAYED AHMED
SAYED@JUSTETC.NET
JUST ET CETERA TECHNOLOGIES (JUSTETC.NET)
 Kind of introduction
 You may find it kind of random though not totally
 Will show basic examples to create
 Demo using VS
 Also steps using text/articles from web
What is WebAPI?
 ASP.NET Web API. ASP.NET Web API is a framework that makes it easy to
build HTTP services that reach a broad range of clients, including
browsers and mobile devices.
ASP.NET Web API is an ideal
platform for building RESTful
applications on the .NET
Framework.
 Yes webAPI is also of REST kinda
API development
 And I showed you on how to
Engineer an API...
Overview
 HTML5 changed the game
 So Web API is here...
 Purpose:
 Create web-services
 Light weight
 Can serve the purpose of SOAP/WCF
 ASMX web-service applications use Soap style
 Can serve the purpose of REST
 Hence, it might fit better for newer development
 You might still want to use WCF/SOAP to extend existing
applications and that will require extensive interaction
 SOAP is pretty verbose -> too much data (XML)
transferred
 Web API is lightweight
 Rest is also simpler than SOAP
 Web API provided more capability and suites well the
new need
 Ajax based applications though not Web-service –
works kinda that way
Just One Resource
 On Rest API Engineering
 Once I developed kinda from scratch a Rest Api like API (telling like
as it did not implement all the aspects of REST though worked and
implemented like rest)
 Anyway, a resource on REST API design/architecture/engineering
 http://blog.octo.com/en/design-a-rest-api/
 This is the resource..looks pretty comprehensive – just googled it
and found it
 I was actually looking for an article that once I read in the past that
was pretty comprehensive and the stuff seemed to make sense and
great..
 It might be the same stuff...
 Anyway, if you are into REST api design and engineering, you will
find such checklist of a Great Rest API design...
 I can show you some info on Web-API from some
slides..
 One is when to Use API and When to use SOAP/WCF
 You just saw SignalR – duplex communications over HTTP
 I just used it without knowing the term SignalR
 Also, utilized/consumed a Web Service Apparently seemed to be
REST and Web-API in the same applicatiom
 About signal R
 The consumer is showing some stuff using a iframe (src points to
remote url and apparently that remote url was using Webservice )
 Iframe height was changing based on interaction
 Required to keep height consistent without showing scrollbars
 So used post message (kinda html 5 and push) to send the height
info to client and from client using some event retrieved that height
and adjusted the height anyway...
 REST and Restlike API/Webservice
 Reaches to different end point based on URL
parameters...
 On How to Test Web API
 Tools that will help
 Anyway...
 Better going for implementation then too much theory
 You can see an example at
 http://www.asp.net/web-api/overview/getting-started-
with-aspnet-web-api/tutorial-your-first-web-api
 Will show you the steps from that URL and then
 Will implement that simple application using Visual
Studio
 So what did we see..
 A sample application returning
 All products
 And might be returning only one product based on url
and if a product id is there..
 Telling might because..I just googled and found this
application...did not check it yet...
 But from REST concept this is what it seems like
 So steps...
 Creat web application
 Select web-api as a type
 Then you create a model – product
 And you add some product in code as just demo...
 In many cases...you might go for entity framework and
anyway..
 Then as usual create controller to utilize the model
 Then you create a HTML file
 From that file you call the API using jQuery
 Based on the URL you will get all products or one
product..
 Let’s see the screenshots..
 Controller MethodURI
 GetAllProducts/api/products
 GetProduct/api/products/id
 So I downloaded the project
 This is how it looks like..
 Does not
 After downloading the project I just added the HTML page—it was
not there
 You can see jquery code to get the product using Web-Api
 function find() {
 var id = $('#prodId').val();
 $.getJSON(uri + '/' + id)
 .done(function (data) {
 $('#product').text(formatItem(data));
 })
 .fail(function (jqXHR, textStatus, err) {
 $('#product').text('Error: ' + err);
 });
 }
 You might see the similar structure in the regular
 Ajax application
 Asmx
 It is just how Web API works internally
 Externally, and for the project structure – very similar to
other...
 The backend implementation of Web API
 If you want to go for implementing that or who
implemented that...that’s based on Huge Theory...
 Such data/database actually belongs to Model
 And are returned to controller then returned to view
 It was kept in controller just for demo and simplicity I
believe
Let’s Implement on our own
 Did a mistake – wanna do again
 Will add model..
 Add controller...
 You see rest like methods...
 Get put delete...
 Did not work
 Internal server error
 Apparently, we need json package as we are usinf
$.getJson
 Will try newtonsoft json
 Don’t see exact match trying one
 If does not work, will being the dll files from the
downloaded application
 It might be an interference with the old application
that we ran before..
 The issue multiple model and controller with same
name..mistakenly
 So worked...
 The routing
 // Web API configuration and services
 // Web API routes
 config.MapHttpAttributeRoutes();
 config.Routes.MapHttpRoute(
 name: "DefaultApi",
 routeTemplate: "api/{controller}/{id}",
 defaults: new { id = RouteParameter.Optional }
 );

More Related Content

PDF
React For Vikings
DOC
Reviews SEO Tools
PDF
Wordcamp Toronto Presentation
PPT
Creating A Vba Function Library For Use In QTP/VBSCRIPT
KEY
Architecting single-page front-end apps
PPTX
Lightning page optimization & best practices
PPTX
Selenide vs. Selenium: The War Of Technologies
PPTX
Angular elements - embed your angular components EVERYWHERE
React For Vikings
Reviews SEO Tools
Wordcamp Toronto Presentation
Creating A Vba Function Library For Use In QTP/VBSCRIPT
Architecting single-page front-end apps
Lightning page optimization & best practices
Selenide vs. Selenium: The War Of Technologies
Angular elements - embed your angular components EVERYWHERE

What's hot (20)

PPTX
SharePoint Framework, Angular and Azure Functions
PPTX
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
PDF
The Asynchronous Pattern (for beginners)
PDF
How to automated test a web application with sending e mail feature
PPT
Controls
PDF
An Introduction to ReactNative
KEY
Namespace less engine
PPTX
Intro to Rails Give Camp Atlanta
PPT
Model View Controller
PPT
ASP.NET AJAX Basics
PPTX
Catalog display
PPT
Services Apps Iand Flex Applications
PPT
ASP.NET AJAX with Visual Studio 2008
PPT
jQuery Intro
PDF
React with Ref
PPT
ASP.NET Session 9
PPTX
Dash of ajax
PPT
Web Os Hands On
ODP
PPTX
Introduction of ASP.NET MVC and AngularJS
SharePoint Framework, Angular and Azure Functions
Colin Bowern - The Not So Scary Side Of Asp.Net – Model View Controller In Th...
The Asynchronous Pattern (for beginners)
How to automated test a web application with sending e mail feature
Controls
An Introduction to ReactNative
Namespace less engine
Intro to Rails Give Camp Atlanta
Model View Controller
ASP.NET AJAX Basics
Catalog display
Services Apps Iand Flex Applications
ASP.NET AJAX with Visual Studio 2008
jQuery Intro
React with Ref
ASP.NET Session 9
Dash of ajax
Web Os Hands On
Introduction of ASP.NET MVC and AngularJS
Ad

Similar to Will be an introduction to (20)

PDF
Web driver selenium simplified
PDF
Progressive EPiServer Development
PDF
WordPress and Client Side Web Applications WCTO
PPT
ASP.net MVC CodeCamp Presentation
PPTX
Web API with ASP.NET MVC by Software development company in india
PPT
AspMVC4 start101
PDF
Into The Box | Alexa and ColdBox Api's
PDF
Mastering Cypress API Testing_ A Comprehensive Guide with Examples.pdf
PPT
Getting Started with Zend Framework
PDF
Building a Single Page Application with VueJS
PDF
Using HttpWatch Plug-in with Selenium Automation in Java
PDF
How to develop an API with PHP, JSON, and POSTMAN in 9 Steps.pdf
PPT
Web Application Introduction
PPT
Web Application Introduction
PPT
Web Application Introduction
PDF
Express node js
PPTX
Designing CakePHP plugins for consuming APIs
PDF
StackMob & Appcelerator Module Part One
PPTX
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
PDF
How to build integrated, professional enterprise-grade cross-platform mobile ...
Web driver selenium simplified
Progressive EPiServer Development
WordPress and Client Side Web Applications WCTO
ASP.net MVC CodeCamp Presentation
Web API with ASP.NET MVC by Software development company in india
AspMVC4 start101
Into The Box | Alexa and ColdBox Api's
Mastering Cypress API Testing_ A Comprehensive Guide with Examples.pdf
Getting Started with Zend Framework
Building a Single Page Application with VueJS
Using HttpWatch Plug-in with Selenium Automation in Java
How to develop an API with PHP, JSON, and POSTMAN in 9 Steps.pdf
Web Application Introduction
Web Application Introduction
Web Application Introduction
Express node js
Designing CakePHP plugins for consuming APIs
StackMob & Appcelerator Module Part One
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
How to build integrated, professional enterprise-grade cross-platform mobile ...
Ad

More from Sayed Ahmed (20)

PDF
Workplace, Data Analytics, and Ethics
PPTX
Python py charm anaconda jupyter installation and basic commands
PPTX
[not edited] Demo on mobile app development using ionic framework
PPTX
Sap hana-ide-overview-nodev
PPTX
Invest wisely
PPTX
Whm and cpanel overview hosting control panel overview
PPTX
Web application development using zend framework
PPTX
Web design and_html_part_3
PPTX
Web design and_html_part_2
PPTX
Web design and_html
PPTX
Visual studio ide shortcuts
PPTX
Virtualization
PPT
User interfaces
PPT
Unreal
PPTX
Unit tests in_symfony
PPTX
Telerik this is sayed
PPTX
System analysis and_design
PPTX
Symfony 2
PPT
Story telling and_narrative
PPTX
Some skills required to be a computer hardware engineer professional
Workplace, Data Analytics, and Ethics
Python py charm anaconda jupyter installation and basic commands
[not edited] Demo on mobile app development using ionic framework
Sap hana-ide-overview-nodev
Invest wisely
Whm and cpanel overview hosting control panel overview
Web application development using zend framework
Web design and_html_part_3
Web design and_html_part_2
Web design and_html
Visual studio ide shortcuts
Virtualization
User interfaces
Unreal
Unit tests in_symfony
Telerik this is sayed
System analysis and_design
Symfony 2
Story telling and_narrative
Some skills required to be a computer hardware engineer professional

Recently uploaded (20)

PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Network Security Unit 5.pdf for BCA BBA.
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Machine learning based COVID-19 study performance prediction
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Unlocking AI with Model Context Protocol (MCP)
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
NewMind AI Weekly Chronicles - August'25 Week I

Will be an introduction to

  • 1. Will be an introduction to Web API SAYED AHMED SAYED@JUSTETC.NET JUST ET CETERA TECHNOLOGIES (JUSTETC.NET)
  • 2.  Kind of introduction  You may find it kind of random though not totally  Will show basic examples to create  Demo using VS  Also steps using text/articles from web
  • 3. What is WebAPI?  ASP.NET Web API. ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.  Yes webAPI is also of REST kinda API development  And I showed you on how to Engineer an API...
  • 4. Overview  HTML5 changed the game  So Web API is here...  Purpose:  Create web-services  Light weight  Can serve the purpose of SOAP/WCF  ASMX web-service applications use Soap style  Can serve the purpose of REST  Hence, it might fit better for newer development  You might still want to use WCF/SOAP to extend existing applications and that will require extensive interaction
  • 5.  SOAP is pretty verbose -> too much data (XML) transferred  Web API is lightweight  Rest is also simpler than SOAP  Web API provided more capability and suites well the new need  Ajax based applications though not Web-service – works kinda that way
  • 6. Just One Resource  On Rest API Engineering  Once I developed kinda from scratch a Rest Api like API (telling like as it did not implement all the aspects of REST though worked and implemented like rest)  Anyway, a resource on REST API design/architecture/engineering  http://blog.octo.com/en/design-a-rest-api/  This is the resource..looks pretty comprehensive – just googled it and found it  I was actually looking for an article that once I read in the past that was pretty comprehensive and the stuff seemed to make sense and great..  It might be the same stuff...  Anyway, if you are into REST api design and engineering, you will find such checklist of a Great Rest API design...
  • 7.  I can show you some info on Web-API from some slides..  One is when to Use API and When to use SOAP/WCF
  • 8.  You just saw SignalR – duplex communications over HTTP  I just used it without knowing the term SignalR  Also, utilized/consumed a Web Service Apparently seemed to be REST and Web-API in the same applicatiom  About signal R  The consumer is showing some stuff using a iframe (src points to remote url and apparently that remote url was using Webservice )  Iframe height was changing based on interaction  Required to keep height consistent without showing scrollbars  So used post message (kinda html 5 and push) to send the height info to client and from client using some event retrieved that height and adjusted the height anyway...
  • 9.  REST and Restlike API/Webservice  Reaches to different end point based on URL parameters...
  • 10.  On How to Test Web API  Tools that will help  Anyway...  Better going for implementation then too much theory
  • 11.  You can see an example at  http://www.asp.net/web-api/overview/getting-started- with-aspnet-web-api/tutorial-your-first-web-api  Will show you the steps from that URL and then  Will implement that simple application using Visual Studio
  • 12.  So what did we see..  A sample application returning  All products  And might be returning only one product based on url and if a product id is there..  Telling might because..I just googled and found this application...did not check it yet...  But from REST concept this is what it seems like
  • 13.  So steps...  Creat web application  Select web-api as a type  Then you create a model – product  And you add some product in code as just demo...  In many cases...you might go for entity framework and anyway..
  • 14.  Then as usual create controller to utilize the model  Then you create a HTML file  From that file you call the API using jQuery  Based on the URL you will get all products or one product..  Let’s see the screenshots..
  • 15.  Controller MethodURI  GetAllProducts/api/products  GetProduct/api/products/id
  • 16.  So I downloaded the project  This is how it looks like..  Does not
  • 17.  After downloading the project I just added the HTML page—it was not there  You can see jquery code to get the product using Web-Api  function find() {  var id = $('#prodId').val();  $.getJSON(uri + '/' + id)  .done(function (data) {  $('#product').text(formatItem(data));  })  .fail(function (jqXHR, textStatus, err) {  $('#product').text('Error: ' + err);  });  }
  • 18.  You might see the similar structure in the regular  Ajax application  Asmx  It is just how Web API works internally  Externally, and for the project structure – very similar to other...  The backend implementation of Web API  If you want to go for implementing that or who implemented that...that’s based on Huge Theory...
  • 19.  Such data/database actually belongs to Model  And are returned to controller then returned to view  It was kept in controller just for demo and simplicity I believe
  • 20. Let’s Implement on our own  Did a mistake – wanna do again  Will add model..  Add controller...  You see rest like methods...  Get put delete...  Did not work  Internal server error  Apparently, we need json package as we are usinf $.getJson  Will try newtonsoft json
  • 21.  Don’t see exact match trying one  If does not work, will being the dll files from the downloaded application  It might be an interference with the old application that we ran before..  The issue multiple model and controller with same name..mistakenly  So worked...
  • 22.  The routing  // Web API configuration and services  // Web API routes  config.MapHttpAttributeRoutes();  config.Routes.MapHttpRoute(  name: "DefaultApi",  routeTemplate: "api/{controller}/{id}",  defaults: new { id = RouteParameter.Optional }  );