In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use postman". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Demo available for web services
Flask get post
1. Get request: the parameters of get are obtained through flask.request.args.
Usage scenario: if you only get data from the server and do not have any impact on the server, use the get request at this time
Passing parameters: is the get request to pass parameters in the url and through? To specify key and value, such as
Web request 127.0.0.1:5678/dag/register_name?job_name=jin backend receives request.args.get ('job_name','default') request.args.get (' key') # can get a single value, requestValues = request.args # can get all parameters of get request, return value is ImmutableMultiDict type, requestValues.to_dict () # converts the obtained parameters to dictionary
2. Post request:
Usage scenario: if you want to have an impact on the server, use the post request
Passing parameters: post request parameters are not placed in URL, but are sent to the server in the form of form data
The post request is obtained through flask.request.form
Post request (Content-Type: application/json,) 1. Get unprocessed raw data regardless of the content type. If the data format is json, the json string is obtained, and the sort and request parameters are the same c = request.get_data () 2. The request parameters are processed and the result is in dictionary format, so the sort will be disrupted according to the dictionary collation rule c = request.get_json () 3. Unprocessed raw data can be obtained, and if the data format is json, the json string is obtained, and the sort and request parameters are the same c = request.data4. The request parameters are processed and the result is in dictionary format, so the sorting will be disrupted according to the dictionary collation rule c = request.jsonps: at the beginning, I thought it was a method to call request.json () and then reported an error as follows: Content-Type: application/json Times error 'dict' object is not callable is originally an attribute, so using request.json in this way, it can be used normally.
1.GET request operation:
Result of 2.GET request operation:
Postman sends a post request in json format
Enter the request url: http://127.0.0.1:8081/getmoney in the address bar
Select "POST" mode
Add key:Content-Type, value:application/json to "headers"
Click "body", "raw''" and set it to JSON
Add:
{"userid": 1}
Just click send to send.
=
Question and answer time: connect
How does an 1.http post request send json data
Add: Content-Type:application/json to the header of the http request so that json data can be sent
This tool briefly describes:
1. This online tool supports requests such as interface http post,get,put,delete,head,trace,options,patch, and supports proxy requests with cookie header and ip
two。 Can generate api interface documentation, this site provides both api interface stress test and websocket test. two。 When accessing the interface to be logged in, you can manually fill in cookie. Or access the interface domain name in Google browser, press F12, under network, click on the icon, and copy it directly into the cookie of this tool. You can access it with cookie, without having to fill in it manually.
3.header can be entered manually (custom header information). You can also get the header information in the browser's network and enter it directly into the header input box of this tool.
Vernacular http request:
To test and use the http interface, you must first understand what a http request is:
Http request: generally speaking, it sends the things of the client to the server through the http protocol, and the server parses the things sent by the client according to the definition of the http protocol!
Get and post request parameters are commonly used in http requests
The get parameter is concatenated after the url to "?" Connect the domain name and parameters to form a get request
For example, after the http://coolaf.com?a=b&c=d, question mark is the get request parameter (request.args.get ('nasty,' 100'))
The post request will not be seen in the url, but will be placed in the body of the http request. Each language will encapsulate the function and parse the post request parameters in the body. What does the post parameter look like? It can be any form, the common form of key=value, the same as the get request format "a=b&c=d" this, in addition, the json,xml format is also common. When these formats are delivered, they will be affected by Content-Type. If different Content-Type delivery formats are different, the server will use the
Content-Type parses the corresponding format. The client and the server use these protocols to distinguish what format is transmitted. Be sure to know.
For the common Content-Type, please see the Content-Type link above for more information. Content-Type:application/x-www-form-urlencoded, similar to form forms and get,post requests, are in this format, such as "a=b&c=d", and the server will automatically parse
If you want to send Content-Type:application/json in json format, you need to add this Content-Type to request header.
Type, the acceptance of this form of server is not the same, it is generally not resolved to the post request, and generally needs to be obtained by reading the body stream.
The above are two common transmission formats, and sometimes we don't have to write our own code, because some of them have been added automatically in the class library, so
You don't need to add it yourself. Content-Type is very important. It affects the format you pass.
Also note in the http request is header, which is divided into request header (request information) and response header (response information).
Request header is sent when the client requests, telling the server about your client, and how the server needs to return it to you, for example, whether to compress it.
(Accept-Encoding:gzip, deflate, sdch) this is to tell the server that I support these kinds of compression. When you return, you can choose one to compress the data, and I can unlock it. And whether to cache, accepted language, User-Agent,referer, etc., cookie is also put into the request header to pass to the server, so as to achieve login. So request header tells the server what you have or parameters are passed. These are defined by the http protocol, and everyone can parse according to this rule. In addition, header can be customized, and you can add any variables to it. So the information in header can be arbitrarily modified and sent to
On the server side.
Response header relative to request header is the information given by the server to the client, some of which are the response given by the server according to the needs of the client, and some of the other information that the server tells the client, such as request protocol, request status code, whether to cache or not, setting the cookie is also returned in response header, and the browser will set it to the browser when it receives it. There is no end to learning. Http is not magical. Make more use of the browser's F12 and take a look at network. Over time, there will be unexpected results.
That's all for the content of "how to use postman". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.