HTTP GET请求方法用于从服务器检索数据。数据由唯一的URI(统一资源标识符)标识。
GET请求可以使用“Query String Parameters”将参数传递给服务器。例如,在下面的请求中,
https://postman-echo.com/get?param1=51zxw¶m2=66666
请求说明
?
后面接参数&
连接多个参数参数编辑
响应数据 在主界面下方一栏菜单为响应菜单栏,可以查看响应内容,Cookie、Headers、响应状态码等信息。
返回值:
{
"args": {
"param1": "51zxw",
"param2": "66666"
},
"headers": {
"host": "postman-echo.com",
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"cache-control": "no-cache",
"cookie": "sails.sid=s%3AybUTdbjW9tK6kEGK3wv5nqjDrGI_nWri.ZbeeTsLGoBJgWngTuBhBUKo9upgIWer2CRdxWttbV1U",
"postman-token": "f19b9f19-f0af-45ff-8dfd-0d1c75c1bbad",
"user-agent": "PostmanRuntime/7.1.5",
"x-forwarded-port": "443",
"x-forwarded-proto": "https"
},
"url": "https://postman-echo.com/get?username=51zxw&password=66666"
}
HTTP POST请求方法旨在将数据传输到服务器,返回的数据取决于服务器的实现。POST请求可以使用Query String Parameters
以及body
将参数传递给服务器。
在下面的请求中,使用Query String Parameters
传递参数。
https://postman-echo.com/post?param=51zxw
返回值
{
"args": {
"param": "51zxw"
},
"data": {},
"files": {},
"form": {},
"headers": {
"host": "postman-echo.com",
"content-length": "0",
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"cache-control": "no-cache",
"content-type": "",
"cookie": "sails.sid=s%3A4L3j09wwnJ9JguJC-raHVYeuyVVEVHGW.za7nk%2BO4gj9Nh%2FJDLzSZczT4k%2BROeV0yTq8GJ5Y9YZo",
"postman-token": "b34668bf-3850-4573-b196-bab2bd7db705",
"user-agent": "PostmanRuntime/7.1.5",
"x-forwarded-port": "443",
"x-forwarded-proto": "https"
},
"json": null,
"url": "https://postman-echo.com/post?param=51zxw"
}
发送一个Request,其中body为application/x-www-form-urlencoded
类型,参数分别为param1=zxw
和param2=888
请求URL如下:
https://postman-echo.com/post
Postman Body数据类型说明:
multipart/form-data
是Web表单用于传输数据的默认编码。这模拟了在网站上填写表单并提交它。表单数据编辑器允许我们为数据设置键-值对。我们也可以为文件设置一个键,文件本身作为值进行设置。Content-Type
标题,这将覆盖Postman定义的设置。返回值如下:
{
"args": {},
"data": "",
"files": {},
"form": {
"param1": "zxw",
"param2": "888"
},
"headers": {
"host": "postman-echo.com",
"content-length": "21",
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded",
"cookie": "sails.sid=s%3A69wx4iZKJDDB1qVsZUnB1RpcwTU-fN_9.pr%2FiwjJzIFDiC9H7dFnINqMwkenjTJnwF8thN15KBzw",
"postman-token": "09d8e786-834a-42b9-bbe0-3e6886ef7b3b",
"user-agent": "PostmanRuntime/7.1.5",
"x-forwarded-port": "443",
"x-forwarded-proto": "https"
},
"json": {
"param1": "zxw",
"param2": "888"
},
"url": "https://postman-echo.com/post"
}
HTTP PUT请求主要是从客户端向服务器传送的数据取代指定的文档的内容。
PUT请求可以使用Query String Parameters
以及body
请求体将参数传递给服务器。
案例:
发送PUT请求,并传递字符参数“hello 51zxw”
https://postman-echo.com/put
返回值
{
"args": {},
"data": "",
"files": {},
"form": {
"hello 51zxw": ""
},
"headers": {
"host": "postman-echo.com",
"content-length": "11",
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded",
"cookie": "sails.sid=s%3A-kzZXqiAKlk9oDgVADnLyqAEf7f6scDV.dhZZMReTg2y9KuTE%2Fxb9O2qGKnaUxD3O%2B3J4PTTXZms",
"postman-token": "1338c8b1-b502-45f6-9400-7be048d7b2ea",
"user-agent": "PostmanRuntime/7.1.5",
"x-forwarded-port": "443",
"x-forwarded-proto": "https"
},
"json": {
"hello 51zxw": ""
},
"url": "https://postman-echo.com/put"
}
HTTP DELETE方法用于删除服务器上的资源,DELETE请求可以使用Query String Parameters
以及body
请求体将参数传递给服务器。delete请求
https://postman-echo.com/delete
返回值
{
"args": {},
"data": {},
"files": {},
"form": {},
"headers": {
"host": "postman-echo.com",
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"cache-control": "no-cache",
"cookie": "sails.sid=s%3A-kzZXqiAKlk9oDgVADnLyqAEf7f6scDV.dhZZMReTg2y9KuTE%2Fxb9O2qGKnaUxD3O%2B3J4PTTXZms",
"postman-token": "065cb8c4-cea2-4e24-9be0-573d58b4da2c",
"user-agent": "PostmanRuntime/7.1.5",
"x-forwarded-port": "443",
"x-forwarded-proto": "https"
},
"json": null,
"url": "https://postman-echo.com/delete"
}
Request Header(请求头)用来说明服务器要使用的附加信息,比较重要的信息有 Cookie、Referer、User-Agent 等。在Postman中可以在请求下方的Headers栏目来设置,如下如图所示:
Response Header(响应头)其中包含了服务器对请求的应答信息,如 Content-Type、Server、Set-Cookie 等,在Postman主界面下方Headers或者Postman Console界面都可以查看Response Header信息。
Tips:通过Postman Console可以看到每次请求的Request Header详细信息。