Usage scenarios

When testing interface requests, we usually use Postman as the interface testing tool

By reference

  • get
  • post

There are only two listed here, and those are the ones that we normally use the most

Postman provides us with the following method for making parameter requests

Here specifically say the following several

  • form-data

    Multipart /form-data can upload files as well as key-value pairs. Multipart /form-data uses key-value pairs so that multiple files can be uploaded.

    It’s after H5, the form form, if you select this method to transfer. The transfer data from the entire form is put into an object and transferred.

    Files must be uploaded in this way

  • x-www-form-urlencoded

    Application/X-www-from-urlencoded data will be coded into key-value pairs, for example,name=Java&age = 23. The data submitted in the form is encoded by urlencode and then transmitted

    If we directly enter Baidu in the browser, as shown in the picture below

    So if I just hit enter, it would look something like this

    In this case, if we copy and paste the address, we will find that the code is automatically transcoded as follows

    https://www.baidu.com/s?ie=UTF-8&wd=%E7%99%BE%E5%BA%A6
    Copy the code

    This is transcoding through the browser. So use header declarations in post requests

  • raw

    You can upload text in any format, including Text, JSON, XML, and HTML

  • binary

    Content-type :application/octet-stream: only binary data can be uploaded. It is usually used to upload files. There are no keys, so only one file can be uploaded at a time.

multipart/form-datawithx-www-form-urlencodedThe difference between

  • Multipart /form-data: you can upload binary data, such as files, as well as form key-value pairs, which are converted into a message at the end

  • X-www-form-urlencoded: Only key-value pairs can be uploaded, and key-value pairs are &coded.

Content-Type

Content-Type: text/plain; charset=utf-8
Copy the code
  • text/plain: plain text
  • text/htmlThe browser can parse the tags in the content, for example:<h1>,<br>Etc.
  • application/json: The value is in the json format