Detailed steps for JMeter to set request header information

In the process of using JMeter, we will encounter scenarios where request header information needs to be set. for example:

  1. The Body data passed by POST is in json format. Need to add header information: Content-Type: application/json.
  2. Use token in the header to pass the user's authentication information.

Next, let's introduce JMeter's method of setting HTTP request headers in detail.

1 Add request header

Right-click HTTP Request and select: Add > Config Elements > HTTP Header Management.

insert image description here

Click the "Add" button at the bottom to add header information, and enter the name and value of the header.

insert image description here

2 Modify the request header

Double-click the name or value of the request header to be modified to enter the editing state. When the input box loses focus, it will be saved automatically.

insert image description here

3 Add tests

We add a "view result tree" point listener to see if the header information is added. Right-click on the thread group and select: Add > Monitor > View Results Tree.

insert image description here

4 Run the test

Click the "Run" button in the toolbar to run the test. The test results will be displayed in the listener of the "View Results Tree".

insert image description here

From the figure above, we can see that the content-type of the request header we created: application/json is added.

We can feel: using JMeter is cumbersome. To create an HTTP interface, set the HTTP request header, call the interface, and view the result returned by the interface, you need to switch between 4 different windows. Here, I highly recommend Apifox. It is very convenient to use Apifox to do the same task: you can create the interface, set the request header, call and view the result on one page.

insert image description here

If you want to comprehensively improve the efficiency of API development and testing, use Apifox.

Finally: In order to give back to the die-hard fans, I have compiled a complete software testing video learning tutorial for you. If you need it, you can get it for free【保证100%免费】
insert image description here

Software Testing Interview Documentation

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.

insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/m0_67695717/article/details/131982801