一、在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); });