一、在CentOS上安裝Postman
wget
)直接獲取最新版本:wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
。sudo mkdir -p /usr/local/postman && sudo tar -zxvf postman.tar.gz -C /usr/local/postman
。/usr/bin
目錄:sudo ln -s /usr/local/postman/Postman/Postman /usr/bin/postman
。sudo touch /usr/share/applications/postman.desktop
創建桌面文件;vim
)編輯該文件,添加以下內容:[Desktop Entry]
Encoding=UTF-8
Name=Postman
GenericName=Api Tools
Comment=Postman
Exec=/usr/bin/postman
Terminal=false
MimeType=text/plain
Icon=/usr/local/postman/Postman/app/resources/app/assets/icon.png
StartupNotify=true
Categories=Development;
sudo chmod +x /usr/share/applications/postman.desktop
。二、使用Postman連接API
postman
命令啟動。https://jsonplaceholder.typicode.com/posts/1
);Content-Type: application/json
,用于告知服務器請求體的格式)。{"title": "foo", "body": "bar", "userId": 1}
)。三、優化API管理(可選但推薦)
base_url: https://api.example.com
),在請求URL中使用{{base_url}}/endpoint
格式引用變量,便于切換不同環境。pm.test("Status code is 200", function() { pm.response.to.have.status(200); });