How to send POST requests in JMeter

HOME

 

 

How to send HTTP Request in JMeter?


We can perform GET as well as POST operation in JMeter. In this tutorial, we will only explain how we send POST HTTP request in JMeter. In the previous tutorial, I have explained how we can send GET request in JMeter.

Create a Test Plan in JMeter by following below mentioned steps


Step 1 –  Add Thread Group

  • Select Test Plan on the tree
  • Add Thread Group                                                                                                                               To add Thread Group: Right click on the “Test Plan” and add a new thread group: Add -> Threads (Users) -> Thread Group
  • In the Thread Group control panel, enter Thread Properties as follows: We will take an example of row no 5.
    • Number of Threads: 5 – Number of users connects to the target website
    • Loop Count: 5  – Number of time to execute testing
    • Ramp-Up Period: 5 – It tells JMeter how long to delay before starting the next user. For example, if we have 5 users and a 5 -second Ramp-Up period, then the delay between starting users would be 1 second (5 seconds /5 users)
  • Step 2 –  Adding JMeter elements  

The JMeter element used here is HTTP Request Sampler. In HTTP Request Control Panel, the Path field indicates which URL request you want to send
Add HTTP Request Sampler
               To add: Right-click on Thread Group and select: Add -> Sampler -> HTTP Request

Below mentioned are the values use in HTTP Request to perform the test

  • Name – HTTP Request 
  • Server Name or IP – localhost
  • Port – 8000
  • Method – POST
  • Path – /demo/helloworld

Add HTTP Head Manager – The Header Manager lets you add or override HTTP request headers, like can add Accept-Encoding,Accept,Cache-Control

To add: Right-click on Thread Group and select: Add -> Config Element -> HTTP Read Manager
Below mentioned are the values use in Http Request to perform the test
Content-type = application/json
accept – application/json

Step 3 – Adding Listeners to Test Plan


Listeners – They shows the results of the test execution. They can show results in a different format such as a tree, table, graph or log file
We are adding View Result Tree listener
View Result Tree – View Result Tree show results of the user request in basic HTML format
To add: Right click Test Plan, Add -> Listener -> View Result Tree

Aggregate Report – It is almost same as Summary Report except Aggregate Report gives few more parameters like, “Median”, “90% Line”, “95% Line” and “99% Line”.

                To add: Right Click on Thread Group > Add > Listener > Aggregate Report

Step 4 – Save the Test Plan

           To Save: Click File Select -> Save Test Plan as ->Give name of the Test Plan. It will be save as .jmx format.

Step 5  – Run the Test Plan

             Click on Green Triangle as shown at the top to run the test.

Step 6 – View the Execution Status

             Click on View Result Tree to see the status of Run. Successful request will be of Green color in the Text Section.

Click on Response data and Response Header to view other information about Response.

 Click on Aggregate Report Result to see the aggregated status of Run.

3 thoughts on “How to send POST requests in JMeter

  1. Hi Dheeraj. If you means to ask that in request body you want to pass different values something like this{ \”source\”:\”${SOURCE_NAME}\”, \”schema\”: \”star\”, \”service\”: \”windows\”}Yes, we can send different values by using Random Variable (Config Element) or getting different values in .csv and passing them to the request

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s