Basic usage of Postman software: The browser copies the request information and imports it into the software to test and send requests.

  This article introduces how to obtain a certain request information in a web page in a browser, import it into the Postman software, and perform API request testing.

  Postman is a popular API development and testing tool that provides a user-friendly interface for creating, testing, debugging, and documenting APIs . This article will introduce the most basic usage of this tool - importing web page requests and configuring relevant Headers , Body and other information to test the requests.

  Without further ado, let’s get started. First, in order to obtain the information requested by the web page from the browser, we need to access the specified web page in the browser (I am using the Chrome browser here, because Chrome supports exporting the request information in cURL format, which is relatively more convenient. But it’s okay if you don’t use cURL format); then, press F12the button to open the developer mode and select the “ Network ” option, as shown in the figure below; then, we need to refresh the web page again. At this point, we can see the names and information of each content in the current web page.

  As shown in the figure above, this article takes the item named in a certain web page NSWas an example to introduce the subsequent operations. Next, we NSWright-click on the file and select the " Copy as cURL Format " option, as shown in the figure below. If your browser does not have this option, you can directly copy the requested link, but you need to manually configure other requested information (such as Headers ) later - so cURL format requests are more convenient to use, because in addition to The link itself can also be accompanied by other requested information, so we do not need to manually configure it one by one.

  Next, in the Postman software, select the “ Import ” option as shown in the image below.

Then, paste the cURL or ordinary URL   we just copied here; as shown in the figure below.

  Then, you will see the interface as shown below. At this time, if you copied a cURL format request when you " Import " earlier , then as long as there are no other problems with this request, and after adjusting the type of our request (such as request, request, etc.) on the left side of the figure below, click Click the " Send " option in the purple box on the right side of the picture below to make a request. If you are using a request in URL format, you need to manually configure the headers , body and other information of the request (if this information is necessary); you can continue to read the following article for the specific configuration method.GETPOST

  In my case, although the request in cURL format is copied during " Import " , due to some problems with my request, I can't see any information in " Response " after sending the request.

  I need to manually add an additional Headers here ; as shown in the figure below. Of course, everyone can modify it based on their own request.

  When configuring Headers , we can either adjust the key-value pair of each Header as shown in the figure above, or we can use the " Bulk Edit " method in the figure below to configure multiple Headers in batches .

  As shown in the figure below, we can directly copy the information of multiple Headers for batch configuration. It should be noted that during batch configuration, one line is a Headers , and the key and value of each Headers: are separated by English colons . At the same time, //unnecessary Headers can be commented out .

  After configuring the corresponding information, we can " Send " our request again; if we see the information as shown in the figure below in " Response ", it means that our request is correct and the content is returned normally; from the upper right of the figure below As can be seen from the corner, the HTTP status code returned by the request is 200, no problem.

  At this point, you're done.

Welcome to follow: Crazy Learning GIS

Guess you like

Origin blog.csdn.net/zhebushibiaoshifu/article/details/132383361