这些操作作为标准库的一部分,在所有 Runbooks 中均可使用。
send_http_request
std::send_http_request 操作向指定的 URL 发送 HTTP 请求。
输入
| 名称 | 是否必填 | 类型 | 描述 |
|---|---|---|---|
url | 必填 | string | 请求发送的目标 URL |
method | 可选 | string | HTTP 方法(GET、POST、PUT、DELETE),默认值:GET |
headers | 可选 | map | 请求中包含的 HTTP 标头 |
body | 可选 | string | 请求正文(用于 POST/PUT 请求) |
timeout_ms | 可选 | integer | 请求超时时间(毫秒) |
输出
| 名称 | 类型 | 描述 |
|---|---|---|
status_code | integer | HTTP 状态码 |
body | string | 响应正文 |
headers | map | 响应标头 |
action "api_call" "std::send_http_request" {description = "Fetch data from API"url = "https://api.example.com/data"method = "GET"headers = {"Authorization" = "Bearer ${variable.token}"}}output "response" {value = action.api_call.body}output "status" {value = action.api_call.status_code}
POST 请求示例
action "create_resource" "std::send_http_request" {description = "Create a new resource"url = "https://api.example.com/resources"method = "POST"headers = {"Content-Type" = "application/json"}body = {"name" = variable.name,"value" = variable.value}}
Is this page helpful?