.Net Interview Questions
Open in Telegram
1 794
Subscribers
+124 hours
+207 days
+4930 days
Posts Archive
"PUT" puts a file or resource at a particular URI and exactly at that URI. If there is already a file or resource at that URI, PUT changes that file or resource. If there is no resource or file there, PUT makes one
POST sends data to a particular URI and expects the resource at that URI to deal with the request. The web server at this point can decide what to do with the data in the context of specified resource
PUT is idempotent meaning, invoking it any number of times will not have an impact on resources.
However, POST is not idempotent, meaning if you invoke POST multiple times it keeps creating more resources
No, you are not supposed to use PUT for GET. GET operations should only have view rights, while PUT resource is used for updating a data.
• GET: It requests a resource at the request URL. It should not contain a request body as it will be discarded. Maybe it can be cached locally or on the server.
• POST: It submits information to the service for processing; it should typically return the modified or new resource
• PUT: At the request URL it update the resource
• DELETE: At the request URL it removes the resource
• OPTIONS: It indicates which techniques are supported
• HEAD: About the request URL it returns meta information
The architectural style for creating web API are
• HTTP for client server communication
• XML/JSON as formatting language
• Simple URI as the address for the services
• Stateless communication
REST represents REpresentational State Transfer; it is a relatively new aspect of writing web API.
RESTFUL is referred for web services written by applying REST architectural concept are called RESTful services, it focuses on system resources and how state of resource should be transported over HTTP protocol to different clients written in different language. In RESTFUL web service HTTP methods like GET, POST, PUT and DELETE can be used to perform CRUD operations.
Web service APIs that comply with REST principles are called RESTful APIs. You can define the RESTful APIs using:
• A base URI - Unique resource identifier.
• HTTP methods - GET, PUT, POST, PATCH, DELETE mapped with CRUD operations.
• A media type for data - used to exchange the information using data formats such as JSON (JavaScript Object Notation) and XML.
Some key characteristics of REST includes
• REST is stateless, therefore the SERVER has no state (or session data)
• With a well-applied REST API, the server could be restarted between two calls as every data is passed to the server
• Web service mostly uses POST method to make operations, whereas REST uses GET to access resources
API design is the process of building an intermediary interface for a system to system connection to expose data to application users and developers.
The fundamental API design influences how well users can consume it and the general user experience. This development process does not allow a single approach. Instead, it combines a series of guidelines to meet initial expectations and continue to work consistently. Application programming interface designers closely follow industry best practices, design patterns, API design principles, and user needs to develop software that presents excellent functionality.
REST stands for REpresentational State Transfer. REST is web standards based architecture and uses HTTP Protocol for data communication. It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods. REST was first introduced by Roy Fielding in 2000.
In REST architecture, a REST Server simply provides access to resources and REST client accesses and presents the resources. Here each resource is identified by URIs/ global IDs. REST uses various representations to represent a resource like text, JSON and XML. Now a days JSON is the most popular format being used in web services.
Web API is considered the best choice over WCF because of the following reasons:
• Web API uses all features of HTTP such as URIs, request/response headers, caching, versioning, various content formats, etc.
• One does not have to define or explain any extra config setting for different devices in Web API.
• Web API uses different text formats including XML because of which it is faster and more preferred for lightweight services.
• Web API also supports MVC features whereas WCF does not support MVC features.
• Web API provides more flexibility as compared to WCF.
• Web API uses standard security like token authentication, basic authentication, etc., to provide secure service whereas WCF uses WS-I standard to provide secure service.
