Analog transmission request postman

Copyright: personal essays, problems at work, only to save the document, hoping to help you, please correct me if wrong with progress! Thank you! https://blog.csdn.net/w893932747/article/details/89919549

Inscription: postman always put a lot of time with some requests confused, all resuful online are some of the concepts, said today in a busy, stroking the piece look! Stroked a practical!

 Common status codes: a web server HTTP response status code is three digits

  1. 200: 2 beginning have expressed a request is sent successfully. 200 indicates that the request is sent successfully, the server returns the
  2. 302: 3 have said at the beginning of the redirect. 302 indicates a provisional response now requested resource request from a different URI. For example, open my blog link, when my blog has been deleted, automatically jump to the blog Home Park
  3. 400: 400 indicates that the request sent by the client has a syntax error. 403 does not have access; 404 represents an access page does not exist
  4. 500: 5 at the beginning of all means that the server is abnormal. Internal server 500 represents abnormality; 504 represents a server timeout does not return results

A transmitting ordinary get, post request, without parameters

Java code:

postman:

Two, URI resource identifier

Java code:

restful:

Third, the type of data transmission json: request parameter map set objects

Java code:

postman: Here we must note,

1, the requesting party mode

2, here to design headers, Body two options

headers:Content-Type-------application/json

Body: raw parameters in json format to and received backend parameter names have been otherwise get back less than

,,, ,,, blackboard blackboard knock knock knock knock blackboard blackboard ,,, ,,, ,,, knock knock blackboard blackboard blackboard ,,, ,,, knock knock knock blackboard blackboard ,,,

2019.05.16 supplement

Use postman want to send an object, would like to send a parameter other than the object was thinking about the individual parameters on the address brought over, then test it as a method parameter method can also be put to use specific methods are as follows:

Java code parameters:

postman parameters:

Fourth, the request for a single parameter

Java:

postman:这里和多个参数的一样需要修改headers和Body,只是在Body中传递单个值即可

五、发送get请求,在URL中直接展示参数名称和数值,请求长度有限制

Java:

postman:这里参数和Java代码里的要一致否则获取不到

六、上传文件请求

Java:

postman:这里切记切记,headers中不能有任何配置,否则上传失败!

有关Content-Type属性值有如下编码类型:

  1. multipart/form-data:既可以上传文件等二进制数据,也可以上传表单键值对,只是最后会转化为一条信息;
  2. x-www-form-urlencoded:只能上传键值对,并且键值对都是间隔分开的。

常见的媒体格式类型如下:

  1.     text/html : HTML格式
  2.     text/plain :纯文本格式      
  3.     text/xml :  XML格式
  4.     image/gif :gif图片格式    
  5.     image/jpeg :jpg图片格式 
  6.     image/png:png图片格式

   以application开头的媒体格式类型:

  1.    application/xhtml+xml :XHTML格式
  2.    application/xml     : XML数据格式
  3.    application/atom+xml  :Atom XML聚合格式    
  4.    application/json    : JSON数据格式
  5.    application/pdf       :pdf格式  
  6.    application/msword  : Word文档格式
  7.    application/octet-stream : 二进制流数据(如常见的文件下载)
  8.    application/x-www-form-urlencoded : <form encType=””>中默认的encType,form表单数据被编码为key/value格式发送到服务器(表单默认的提交数据的格式)

body has four options: form-data, x-www-form-urlencoded, raw, binary

a. form-data: either upload key-value pairs, you can also upload files. When the file is uploaded field, there will be explained Content-Type file type, you can upload multiple files.

bx-www-form-urlencoded: data in the form are converted to the key-value pairs, such as, name = java & age = 2, the key pair can only upload

c.raw: Text can be uploaded in any format, you can upload text, json, xml, html, etc.

d.binary: you can only upload binary data, typically used to upload the file, because there is no key, so only upload one file.

Guess you like

Origin blog.csdn.net/w893932747/article/details/89919549