Rest API
Rest API
1 PUT is a technique of altering resources when PATCH is a technique for transforming the resources
the client transmits data that revamps the whole when the client transmits partial data that will be
resource. updated without changing the whole data.
2 The PUT HTTP method is known to be The PATCH HTTP method is believed to be non-
unchanged. That means, if you retry a request idempotent. That means, if you retry the request
numerous times, that will be equal to a single multiple times, you will end up having multiple
request conversion. resources with different URIs.
3 The PUT method has high bandwidth. Whereas, the PATCH method has comparatively low
bandwidth.
8. SOAP vs REST
The term web API generally refers to both sides of computer systems communicating over a network: the API services
offered by a server, as well as the API offered by the client such as a web browser.
The server-side portion of the web API is a programmatic interface to a defined request-response message system, and is
typically referred to as the Web Service. There are several design models for web services, but the two most dominant are
SOAP and REST.
SOAP provides the following advantages when compared to REST:
• Language, platform, and transport independent (REST requires use of HTTP)
• Works well in distributed enterprise environments (REST assumes direct point-to-point communication)
• Standardized
• Provides significant pre-build extensibility in the form of the WS* standards
• Built-in error handling
• Automation when used with certain language products
REST is easier to use for the most part and is more flexible. It has the following advantages when compared to SOAP:
• Uses easy to understand standards like swagger and OpenAPI Specification 3.0
• Smaller learning curve
• Efficient (SOAP uses XML for all messages, REST mostly uses smaller message formats like JSON)
• Fast (no extensive processing required)
• Closer to other Web technologies in design philosophy
10. What are the main components in HTTP request and response?
An HTTP request is divided into three parts: Request line, header and body.
12. Can we use get/post method instead of put method to create resource?
Since both can be used to submit data, you can use either POST or PUT to create or update a resource.
------------------------------------------------------------------------------------------------------------------------------------
Representation of { <Person>
Hierarchy elements “firstName”: “Mr.”, <FirstName>Mr</FirstName>
“lastName”: “A” <LastName>A</LastName>
“details”: [“Height”, “Weight”, “Color”, <Details>
“Age”, “Sex”, “Language”] } <Details>Height</Details>
<Details>Weight</Details>
<Details>Color</Details>
<Details>Age</Details>
<Details>Sex</Details>
<Details>Language</Details>
Popularity reason JSON is less verbose and faster. XML uses more words to describe the
intention. Sometimes it is more than
necessary. Parsing XML software is a
slow and tedious job. This costs in
terms of memory consumption.
Data structure JSON data structure is a map. The map XML is a tree. Means a tree
is similar to key/value pairs and is representation of data. This makes
useful when interpretation and working on XML a tedious and time-
predictability are needed. consuming task.
Data Information JSON is preferred for data delivery XML is preferred for storing information
between servers and browsers. on the server side.
Metadata tagging Putting metadata in the tags is one of In JSON, this is achieved; look how –
the crucial factors XML leads to JSON. The programmer has to make the entity
This is how – This is simple for XML an object; after this, the attribute has to
using attributes. be added as a member of an object.
The point of concern here is the way of
doing this process.
Mixed content Strings are there which contain Considering the JSON, things are pretty
structured markup. Handling this in complex as JSON only contains data. In
XML is easier yet effective. In this doing this, a programmer has to store
process, a programmer has to put the metadata as data again. This adds
marked-up text within a child tag of complexity to the process.
the parent to which it belongs.