Posts

Showing posts from March, 2024

Hypermedia REST API

Image
Hypermedia is nothing but in simple terms it has hyperlinks associated with the API endpoint. It helps the API to link to related resources associated with the endpoint. This reduces the coupling between the server and the client. A hypermedia-driven REST API, often called a HATEOAS (Hypermedia As The Engine of Application State) API, utilizes hypermedia to enable dynamic interactions between clients and servers. In a hypermedia-driven API, clients navigate the API by following hyperlinks embedded within the responses received from the server, rather than relying on predefined URLs or endpoint structures.  Let me take an e-commerce online store as an example to explain more. When I search for a resource namely a product, it associates with its own API endpoint, links to 'Add to Cart', 'Save for Later', 'Buy Now', and 'Similar Products'. These connected links are called  Hypermedia links. I do not need multiple endpoints to refer to other endpoints becaus

Network Protocols

Image
Humans have demonstrated the advantages of using standards and rules in various forms. We follow the food recipe to cook delicious food, follow the ethics governed by the organization in the workplace, follow traffic rules while driving, and many more. Doesn't it apply only to humans? Definitely not! Even computers have certain rules and standards for better performance. There should be a common standard for a system to communicate with other systems because each would have a different operating system, using different programming languages. How should we connect with each other without having any trouble? We call the set of rules and standards "Protocols" for networking. Imagine Network Protocols are like a birthday party invitation. When one computer wants to talk with another, it will send an invitation in a common language they both understand. For example, some computers will speak only Python language and others will speak Java. In this case, for smooth communicatio

HTTP Payloads

Image
 What happens when I send a letter without information to the receiver that I require some details from them? What happens when the receiver writes a response to my letter without having the information I need? This information is similar to the body generally called a payload in HTTP request and response.  Let us see the payload in the HTTP request and HTTP response individually. I have added the below image to explain the HTTP request and response body/payload in JSON. I have used BurpSuite to take this image and Swagger Petstore (petstore.swagger.io) for this example. HTTP Request Payload Generally, the payload is not required for all the requests and responses. GET and HEAD methods usually do not require a body while sending a request to the server. The above example is a POST request to create a resource name 'doggie'. To achieve this, I should send some information about the resource which is called HTTP request payload. Breakdown of request payload: Content-Type:  Specif