Agenda
What is REST API?
Agenda
HTTP Verbs
Agenda
HTTP Status Codes
Agenda
Constraints of C# REST API
Agenda
Implementation
Takeaways
Agenda
What is REST API?
REST is an abbreviation for Representational State Transfer. REST is a distributed system
architectural style.
What is REST API?
It is founded on a set of principles that defines and addresses network resources. RESTful
services communicate using HTTP (HyperText Transfer Protocol).
What is REST API?
The REST system communicates with external systems via web resources identified by URIs
(Uniform Resource Identifiers).
HTTP Verbs
Create
Post
Read
Get
Update
Put
Delete
Delete
HTTP Verbs
Create
Post
Read
Get
Update
Put
Delete
Delete
To insert the data into the database, the
method must be defined as a POST method.
To define a Post method, we decorate a
method with [HttpPost].
HTTP Verbs
Create
Post
Read
Get
Update
Put
Delete
Delete
Retrieving data or information is possible
through the Get verb. To define a Get method
we decorate a method with [HttpGet].
HTTP Verbs
Create
Post
Read
Get
Update
Put
Delete
Delete
To Update or modify the data in the database,
the method must be defined as a PUT method.
To define a Put method we decorate a method
with [HttpPut].
HTTP Verbs
Create
Post
Read
Get
Update
Put
Delete
Delete To Delete the data from the database, the
method must be defined as a DELETE
method. To define a Delete method we
decorate a method with [HttpDelete].
HTTPS Status Codes
1xx Series : Information Codes
2xx Series : Success Codes
3xx Series : Redirect Codes
4xx Series : Client Error Codes
5xx Series : Server Error Codes
HTTPS Status Codes
Status Code Status Description
200 OK
201 Created
202 Accepted
204 No Content
200 Series
HTTPS Status Codes
Status Code Status Description
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
400 Series
HTTPS Status Codes
Status Code Status Description
500 Internal Server Error
501 Not Implemented
503 Service Unavailable
504 Geteway Timeout
500 Series
Constraints of C# REST API
Constraints of C# REST API
Uniform Interface
The uniform interface requirement specifies how clients
and servers interact.
It decouples and simplifies the design, allowing each
component to evolve independently.
Constraints of C# REST API
Stateless
A single client can submit many requests to the server,
but each one must be independent.
Each request must have all of the essential information
for the server to understand and process it properly.
The server must not store any information about the
client's current status in this situation.
Constraints of C# REST API
Client-Server
Client and server are separated due to uniform interface.
Thus, clients aren't concerned with server-side data
storage, boosting code portability.
Servers are simpler and more scalable since they don't
care about user interface or state.
If the interface isn't changed, servers and clients can be
replaced and developed independently.
Constraints of C# REST API
Cacheable
Since many clients connect to the same server and
often ask for the same resources, it is important that
these responses can be cached.
By doing so, unnecessary processing can be avoided,
and overall speed can be considerably improved.
Constraints of C# REST API
Layered System
Normally, a client cannot know whether it is connected
directly to the end server or through an intermediary.
By facilitating load balancing and providing shared
caches, intermediary servers can improve system
scalability.
Security policies can also be enforced by layers.
Demo
End-Result
Takeaway
REST-API serves as the interface, and communication between the client and server
takes place over HTTP.
The REST-API also serves as a gateway or a single point of access into the system.
Takeaway
When a client requests a RESTful API, it sends a representation of the resource's
state to the requester or endpoint.
Takeaway
C# REST API

C# REST API

  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 10.
    What is RESTAPI? REST is an abbreviation for Representational State Transfer. REST is a distributed system architectural style.
  • 11.
    What is RESTAPI? It is founded on a set of principles that defines and addresses network resources. RESTful services communicate using HTTP (HyperText Transfer Protocol).
  • 12.
    What is RESTAPI? The REST system communicates with external systems via web resources identified by URIs (Uniform Resource Identifiers).
  • 14.
  • 15.
    HTTP Verbs Create Post Read Get Update Put Delete Delete To insertthe data into the database, the method must be defined as a POST method. To define a Post method, we decorate a method with [HttpPost].
  • 16.
    HTTP Verbs Create Post Read Get Update Put Delete Delete Retrieving dataor information is possible through the Get verb. To define a Get method we decorate a method with [HttpGet].
  • 17.
    HTTP Verbs Create Post Read Get Update Put Delete Delete To Updateor modify the data in the database, the method must be defined as a PUT method. To define a Put method we decorate a method with [HttpPut].
  • 18.
    HTTP Verbs Create Post Read Get Update Put Delete Delete ToDelete the data from the database, the method must be defined as a DELETE method. To define a Delete method we decorate a method with [HttpDelete].
  • 20.
    HTTPS Status Codes 1xxSeries : Information Codes 2xx Series : Success Codes 3xx Series : Redirect Codes 4xx Series : Client Error Codes 5xx Series : Server Error Codes
  • 21.
    HTTPS Status Codes StatusCode Status Description 200 OK 201 Created 202 Accepted 204 No Content 200 Series
  • 22.
    HTTPS Status Codes StatusCode Status Description 400 Bad Request 401 Unauthorized 403 Forbidden 404 Not Found 400 Series
  • 23.
    HTTPS Status Codes StatusCode Status Description 500 Internal Server Error 501 Not Implemented 503 Service Unavailable 504 Geteway Timeout 500 Series
  • 25.
  • 26.
    Constraints of C#REST API Uniform Interface The uniform interface requirement specifies how clients and servers interact. It decouples and simplifies the design, allowing each component to evolve independently.
  • 27.
    Constraints of C#REST API Stateless A single client can submit many requests to the server, but each one must be independent. Each request must have all of the essential information for the server to understand and process it properly. The server must not store any information about the client's current status in this situation.
  • 28.
    Constraints of C#REST API Client-Server Client and server are separated due to uniform interface. Thus, clients aren't concerned with server-side data storage, boosting code portability. Servers are simpler and more scalable since they don't care about user interface or state. If the interface isn't changed, servers and clients can be replaced and developed independently.
  • 29.
    Constraints of C#REST API Cacheable Since many clients connect to the same server and often ask for the same resources, it is important that these responses can be cached. By doing so, unnecessary processing can be avoided, and overall speed can be considerably improved.
  • 30.
    Constraints of C#REST API Layered System Normally, a client cannot know whether it is connected directly to the end server or through an intermediary. By facilitating load balancing and providing shared caches, intermediary servers can improve system scalability. Security policies can also be enforced by layers.
  • 32.
  • 34.
    Takeaway REST-API serves asthe interface, and communication between the client and server takes place over HTTP.
  • 35.
    The REST-API alsoserves as a gateway or a single point of access into the system. Takeaway
  • 36.
    When a clientrequests a RESTful API, it sends a representation of the resource's state to the requester or endpoint. Takeaway