Rest Client作为替代Postman的方案使用

发布时间 2023-11-14 14:30:28作者: YukiRinLL

Rest Client作为替代Postman的方案使用。

参考链接

VSCode 小鸡汤 第01期 - REST Client 简单好用的接口测试辅助工具

https://zhuanlan.zhihu.com/p/56174598

插件安装

在插件库中搜索"REST Client", 插件大致详情为:
Version: v0.25.1
Publisher: Huachao Mao
Description: REST Client for Visual Studio Code

SSL配置

依次点击 File -> Preferences -> Settings.
从页面中展开Extensions, 拉到下方找到"REST Client"并点开,点击"Certificates"下面的"Edit in setting.json",新增certificates:

    "rest-client.certificates": {
        "servername-prod:8556": {
            "cert": "../xxx_prd.cer",
            "key": "../xxx_prd.key"
        },
        "servername-uat:8556": {
            "cert": "../xxx_uat.cer",
            "key": "../xxx_uat.key"
        },
        "servername-sit:8556": {
            "cert": "../xxx_sit.cer",
            "key": "../xxx_sit.key"
        },
    }

这里面的内容可以从Postman中的"Client certificates"直接对应Copy过来,证书的cer和key对应地址请匹配好本地文件路径。

Environment Variables

示例配置如下:

   "rest-client.environmentVariables": {
        "$shared": {
            "tokenType": "Bearer"
        },
        "DEV": {
            "forgeRockHost": "https://openam-xxx-dev.id.forgerock.io"
        },
        "UAT": {
            "forgeRockHost": "https://openam-xxx-staging.id.forgerock.io"
        },
        "PROD": {
            "forgeRockHost": "https://openam-xxx.id.forgerock.io"
        }
    }

同步与共享

Postman的云同步与共享由于是公网环境,风险较大,对于Rest Client中所有编辑出来的.http文件,建议使用Bitbucket或者OneDrive进行管理,避免公网暴露。