> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/http/http-request.md).

# HTTP请求

### 发送网络请求的操作 (HTTP Request)

HTTP Request 是一种高级操作，用于直接从脚本向服务器、第三方 API 或网站发送网络请求，而无需打开浏览器界面进行手动交互。此操作有助于将数据处理速度提高数十倍。

#### 配置参数解释：

* URL：需要交互的服务器上资源或 API 的路径地址（例如：<https://api.telegram.org/bot.../sendMessage>）。
* Method：用于定义执行操作的通信方法：
  * `GET`：从服务器获取（读取）数据。
  * `POST`：向服务器发送新数据（通常用于登录、创建文章、发送消息）。
  * `PUT` / `PATCH`：更新服务器上已有的数据。
  * `DELETE`：删除服务器上的资源。
* Header：随请求发送的附加信息，以便服务器识别浏览器或验证访问权限。
  * *例如*：`Content-Type: application/json`（发送的数据格式），或 `Authorization: Bearer <token_秘密>`（账户验证配置代码）。
* Data (Body / Payload)：随请求发送的实际数据（仅适用于选择 `POST`、`PUT`、`PATCH` 等方法时）。
* Timeout：最大等待时间（以秒为单位，取决于界面设置），即操作将等待服务器的响应。如果超过此时间而服务器未响应，操作将自动断开连接并报告错误（或抛出异常），以避免脚本因网络延迟或对方服务器崩溃而无限期挂起。
* Use profile's proxy：允许使用分配给该配置文件的代理发送请求的选项。如果未选中，系统将使用您计算机的本地 IP 地址发送请求。

#### 根据内容类型格式化 Data (Body) 部分

根据服务器的 API 文档要求，Data 部分必须按照不同的格式规范填写：

**示例 1：使用 `application/json` 格式的 body**

这是当前与现代 API 工作时最常见的格式。Body 必须按照大括号 `{}` 的结构填写，数据字段必须用双引号包裹，符合 JSON 格式标准。

**示例 2：使用 `application/x-www-form-urlencoded` 格式的 body**

这是传统的数据字符串格式，通常出现在旧的登录表单或某些支付网关中。属性对被连接成一个连续的文本字符串。

**示例 3：使用 `multipart/form-data` 格式的 body**

这是特殊格式，必须在您需要上传文件（如图片、视频、文档文件）或从计算机向服务器发送复杂的混合表单时使用。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/http/http-request.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
