前言
使用 postman 發送 http 協議 post 請求,兩種請求參數類型application/json 和 application/x-www-from-urlencoded。
application/json
請求參數是json格式,這種是最常見的,以登錄接口為例
接口名稱:用戶賬戶登錄
接口地址: /api/v1/login
請求方式: POST
請求參數:

請求示例
# 作者-上海悠悠 QQ交流群:717225969
# blog地址 https://www.cnblogs.com/yoyoketang/
POST http://localhost:8201/api/v1/login HTTP/1.1
Content-Type: application/json;charset=utf-8
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 43
Content-Type: application/json
{
"username": "test",
"password": "123456"
}
postman上新增一個登陸1的請求

請求方式選POST,輸入url地址http://localhost:8201/api/v1/login

請求 body 選 raw,並選擇 application/json類型

輸入json格式的請求參數

請求頭部參數Content-Type: application/json,在前面一步raw選擇application/json類型類型后,會自動添加一個請求頭部參數

查看請求頭部參數:Content-Type: application/json

點send 按鈕就可以發送成功了

測試沒問題后點下save按鈕,這樣左側的圖標就會變成post,會保存前面的請求數據

application/x-www-from-urlencoded
如果請求參數是 application/x-www-from-urlencoded 格式, 如:username=test&password=123456
請求示例
# 作者-上海悠悠 QQ交流群:717225969
# blog地址 https://www.cnblogs.com/yoyoketang/
POST http://localhost:8201/api/v4/login/ HTTP/1.1
Host: 49.235.92.12:7005
User-Agent: python-requests/2.22.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Length: 29
Content-Type: application/x-www-form-urlencoded
username=test&password=123456
postman 上新增一個登陸2的接口請求, body可以直接選擇:x-www-form-urlencoded

這個時候頭部會自動生成一個請求參數Content-Type: application/x-www-form-urlencoded

body部分在表格寫key-value格式的參數

如果參數較多,可以點右側的Bulk Edit按鈕快速編輯,格式如下

點 send 按鈕發 post 請求,沒問題后點 save 按鈕保存

作者-上海悠悠 blog地址 https://www.cnblogs.com/yoyoketang/
