studio-web
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

Studio Web 用户指南

上次更新日期 2025年11月20日

HTTP

The HTTP request activity enables you to perform JSON-based API requests within your workflow. You can use the generic HTTP connector or any of the supported Integration Service connectors for authentication, but you also have the option to use the activity without a connection and provide authentication details directly in the request.

The activity provides full control over request configuration, allowing dynamic definition of methods, URLs, headers, and body content. After execution, the response data becomes available for reference in subsequent workflow steps, making it a critical component for interacting with external APIs.

Note: You can leverage Autopilot to add the HTTP request for you by pasting the desired cURL into the chat.

使用 HTTP 活动

To add an HTTP request activity to your workflow:
  1. 在 API 工作流设计器画布上,选择加号 (+) 图标。系统将显示“添加活动”菜单。
  2. 选择“HTTP”
  3. “属性”面板中,配置以下字段:
    • Authentication—The type of authentication to use, either No authentication or Connector.
    • Connector—If you selected Connector authentication, select the connector to use.
    • Connection—The connection established in Integration Service. Select an existing connection, click + Connection to add a new connection, or click Open connections to manage connections.
    • Method—The HTTP method for the request, GET, POST, PATCH, DELETE, PUT, OPTIONS, or HEAD.
    • Request URL—The API endpoint for the request. You can dynamically build URLs using the Expression editor. For example, appending an ID retrieved from a previous workflow step. If a Base URL is set, enter a relative path. To override it, use an absolute URL with the same base domain.
    • Headers—The request headers as key-value pairs. Headers use a JSON object format and can be generated dynamically with the Expression editor. For example:
      {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Authorization": "Bearer jfio**********"
      }{
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Authorization": "Bearer jfio**********"
      }
    • Query parameters—The query parameters. Use the Dictionary editor to add new parameters.
      • 示例:query value "select * from Vendor"(适用于 QuickBooks Online)。
    • Body—Available for all HTTP methods except GET, OPTIONS, and HEAD. Supports JSON-based payloads, allowing you to reference data from previous step outputs using the Expression editor.
  4. 调试工作流以执行活动并生成输出字段以供以后使用。

HTTP 活动示例

以下示例向 HTTPBin 发出 POST 请求,该请求将返回请求数据以进行验证。请求包含动态路径变量、标头和结构化请求正文。

打开“调试配置”窗口,然后在“项目参数”部分粘贴并保存以下 JSON 语法:

{
  "id": 12345,
  "name": "John Doe",
  "isActive": true,
  "balance": 2500.75,
  "createdAt": "2025-03-25T12:00:00Z",
  "tags": [
    "premium",
    "verified",
    "active"
  ],
  "address": {
    "street": "123 Main St",
    "city": "New York",
    "state": "NY",
    "zipCode": "10001",
    "coordinates": {
      "latitude": 40.7128,
      "longitude": -74.006
    }
  },
  "transactions": [
    {
      "transactionId": "txn_001",
      "amount": 150.5,
      "currency": "USD",
      "timestamp": "2025-03-24T10:30:00Z",
    },
    {
      "transactionId": "txn_002",
      "amount": -75.25,
      "currency": "USD",
      "timestamp": "2025-03-23T08:15:00Z"
    }
  ]
}{
  "id": 12345,
  "name": "John Doe",
  "isActive": true,
  "balance": 2500.75,
  "createdAt": "2025-03-25T12:00:00Z",
  "tags": [
    "premium",
    "verified",
    "active"
  ],
  "address": {
    "street": "123 Main St",
    "city": "New York",
    "state": "NY",
    "zipCode": "10001",
    "coordinates": {
      "latitude": 40.7128,
      "longitude": -74.006
    }
  },
  "transactions": [
    {
      "transactionId": "txn_001",
      "amount": 150.5,
      "currency": "USD",
      "timestamp": "2025-03-24T10:30:00Z",
    },
    {
      "transactionId": "txn_002",
      "amount": -75.25,
      "currency": "USD",
      "timestamp": "2025-03-23T08:15:00Z"
    }
  ]
}
  1. 在 API 工作流设计器画布上,添加“脚本”活动,以输出“持有者令牌”值:
    1. 打开“表达式编辑器”并返回一个 JSON,其属性名为“bearer_token”
      return {
          "bearer_token": "123321123321"
      }return {
          "bearer_token": "123321123321"
      }
    2. 保存
  2. HTTP活动添加到设计器画布中。
  3. 按如下方式配置HTTP活动:
    • 方法— POST
    • 请求 URL — 使用“表达式编辑器”,使用ID路径变量构建 URL 字符串:
      "https://www.httpbin.org/anything/" + ($workflow.input.id)"https://www.httpbin.org/anything/" + ($workflow.input.id)
    • “标头” — 通过指定简单的键值 JSON 来添加标头。您还将模拟添加持有者令牌作为“授权”标头的流程:
      {
          "Accept": "application/json",
          "Content-Type": "application/json",
          "Authorization": ("Bearer " + $context.outputs.Javascript_3.bearer_token)
      }{
          "Accept": "application/json",
          "Content-Type": "application/json",
          "Authorization": ("Bearer " + $context.outputs.Javascript_3.bearer_token)
      }
    • 请求正文— 使用表达式编辑器,通过引用运行配置 JSON,动态构建请求正文。目标是将包含在对象中的事务数组作为请求有效负载传递:
      {
          "transactions": $workflow.input.transactions
      }{
          "transactions": $workflow.input.transactions
      }

    请注意, “表达式输出”面板会根据活动测试输入数据显示最终 JSON 的格式:

    测试输入和输出面板
  4. 调试工作流以执行活动。
  5. 请查看输出面板,以查看 HTTP 响应。
    带响应的调试面板
  • 使用 HTTP 活动
  • HTTP 活动示例

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2025 UiPath。保留所有权利。