Make Selenium Easy

API Testing Tutorial Part 13 – What is a Payload in an API?

As a part of our API Testing series, in this post, we will learn about an important terminology of API called “Payload”.

A Restaurant

Take a real-time scenario. A typical example of a Restaurant. A restaurant serves foods of different cuisines. It may be north Indian, south Indian, Chinese, Italians, etc. Everyone who visits the restaurant will be served on their choice. But there will be a pattern:-

  1. Visit restaurant
  2. Connect with a Waiter.
  3. Give instructions to the waiter.
  4. You will be served as requested food.

The waiter works on specific instructions. If you want a north Indian cuisine food you need to give instructions to a waiter or if you want a south Indian cuisine food you need to give instructions to the waiter. A waiter can not decide what food you want. Similarly, an API works on instructions or Payload.  Foods are resources, a waiter is an API and instructions are payloads at high levels here. So how you will be served depends on what you instruct.

When we launch the Facebook URL then we need to log in with our specific credentials. In response, the Facebook server will return back with the requested user’s profile details. It is a two-way process. Payload as request and payload as a response. Request payload is sent from client to server and response payload is sent from server to client.

There are many ways of providing payload to an API. It may be a JSON, XML, HTML, TEXT, etc but all serve the purpose of giving instruction to an API with different representations.

If we see a Create Booking API of RestFul Booker, you can see how this accepts the same information in two different formats.

JSON Format

XML Format

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappyLearning

Find all Selenium related posts here, all API manual and automation related posts here, and find frequently asked Java Programs here.

Many other topics you can navigate through the menu.

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.

API Testing Tutorial Part 13 – What is a Payload in an API?

by Amod Mahajan time to read: 1 min
0
%d bloggers like this: