需求背景
调用 HTTP 请求的场景非常广泛,几乎涵盖了所有需要进行网络通信和数据交换的情况,以下是一些常见的 HTTP 请求调用场景:网页浏览、API 调用、文件上传和下载、用户身份验证、实时数据更新、第三方服务集成、爬虫和自动化脚本、物联网设备通信等场景等,在微搭中,您可以使用自定义 APIs 方法来发送 HTTP 请求。
实践步骤
1. 前往 APIs 控制台界面,新建 APIs,选择 HTTP 请求。
![](https://qcloudimg.tencent-cloud.cn/image/document/56112e29ec4f181a7e1b838a251f5be0.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/56112e29ec4f181a7e1b838a251f5be0.png)
2. 编辑 APIs 信息,单击右下角创建。
![](https://qcloudimg.tencent-cloud.cn/image/document/ee3ae738a3d405d65f5681500ae7e73e.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/ee3ae738a3d405d65f5681500ae7e73e.png)
3. APIs 方法配置参数预览,主要包含请求 URL、请求 Method、入参、出参。
![](https://qcloudimg.tencent-cloud.cn/image/document/ce239aa19d32ee0b095021aa33c883bc.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/ce239aa19d32ee0b095021aa33c883bc.png)
4. 配置 APIs 方法相关信息。
![](https://qcloudimg.tencent-cloud.cn/image/document/19a755daf3d262aa38de886bc6871610.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/19a755daf3d262aa38de886bc6871610.png)
5. APIs 方法测试以及出参映射。
![](https://qcloudimg.tencent-cloud.cn/image/document/3ee59f09349f479b955cddc6532e8c85.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/3ee59f09349f479b955cddc6532e8c85.png)
6. APIs 方法配置完成。
![](https://qcloudimg.tencent-cloud.cn/image/document/ddb53bbaf3b0f653d5a98dda1ec60a9e.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/ddb53bbaf3b0f653d5a98dda1ec60a9e.png)
7. 编辑器中新建外部 APIs 查询方法。
![](https://qcloudimg.tencent-cloud.cn/image/document/e9d1816d7af0f81de5a88c0a76fbdafe.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/e9d1816d7af0f81de5a88c0a76fbdafe.png)
8. APIs 查询方法配置中选择上述创建的 HTTP 方法。
![](https://qcloudimg.tencent-cloud.cn/image/document/5a95b22a6c56aa8ac93673f804fad995.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/5a95b22a6c56aa8ac93673f804fad995.png)
9. APIs 查询方法入参映射成功。
![](https://qcloudimg.tencent-cloud.cn/image/document/fddccfc02eec0c8f06d89a3bf8579f86.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/fddccfc02eec0c8f06d89a3bf8579f86.png)