- 概述
- 加密
- 数据库
- Java
- Python
- 网页 API

开发者活动
HTTP 请求(旧版)
UiPath.Web.Activities.HttpClient
This activity is available in WebAPI package versions earlier than 2.0.0-preview. For an updated experience, use the improved HTTP Request activity included in WebAPI version 2.0.0-preview.
描述
用于对指定的网页 API 执行 HTTP 请求。首次将此活动拖动至“设计器”面板时,系统会显示“HTTP 请求向导”窗口,从而提供创建请求及预览服务器响应的便捷方法。
If the returned HTTP status code (StatusCode) is 0, it means that the server did not return an actual response for some reason. This usually points to some connectivity or network issues you might be having.
The WebAPI package is not compatible with the following activities: UiPath.Salesforce.Activities and UiPath.Jira.Activities.
项目兼容性
Windows - 旧版 | Windows | 跨平台
Windows、Windows - 旧版配置
导入向导窗口
您可以使用此选项导入 CURL 格式的 HTTP 请求。
HTTP 请求向导窗口
此向导中显示的所有字段也可在“属性”面板中找到。因此,您仍可在关闭向导后编辑首选项。您可以使用硬编码值或变量在向导中配置活动。
When variables are used, the preview functionality is not available.

请求生成器选项卡
- End Point - The URL to which you want to make the request. Custom segments have to be placed between braces "{}" and defined in the Parameters section. For example, this URL
https://platform.uipath.com/odata/Robots(28)can be written ashttps://platform.uipath.com/odata/Robots({id}), and the value of theidparameter can be provided in the Parameters section, as a UrlSegment. - “预览 URL”- 预览“端点”字段中提供的 URL,同时会兼顾“参数”部分提供的信息。
- Enable SSL certificate verification - Check this box to verify SSL certificates when sending a request. Verification failures will result in the request being aborted.
- “超时”- 指定最长等待时间(以毫秒为单位),如果超出该时间后活动并未运行,系统便会抛出错误。默认值为 6000 毫秒(6 秒)。
- Client Certificate - The location in which the Client Certificate file is stored. The full path must be provided. The supported certificate encoding is
X.509and the supported extensions are.pfxand.p12. It supports two-way handshake verification.备注:The path must not be written between quotation marks.
- “客户端证书密码”- 与正在使用的客户端证书文件对应的密码。
- “请求方法”- 调用 API 时使用的请求方法。支持以下 HTTP 动词:“
GET”、“POST”、“PUT”、“DELETE”、“HEAD”、“OPTIONS”、“PATCH”和“MERGE”。系统会默认选择“GET”方法。 - “身份验证”- 指定调用 API 时要使用的身份验证协议。支持的协议如下:
- “无”- 默认选项。如果要向其发送请求的网页服务器不需要身份验证协议,则应使用此选项。
- “简单 Http”- 如果请求的 API 使用简单的 HTTP 身份验证协议,则必须选择此选项。选中后,系统会显示另外两个字段:“用户名”和“密码”。这两个字段必须使用指定 API 的有效凭据进行填充。
- “OAuth1”- 如果请求的 API 使用 OAuth1 协议,则必须选择此选项。选中后,系统会显示以下四个字段:“使用者密钥”、“使用者密码”、“访问令牌”和“访问令牌密码”。
- “OAuth2”- 如果请求的 API 使用 OAuth2 协议,则必须选择此选项。选中后,系统会显示“访问令牌”字段。在响应指定 API 的另一个 HTTP 请求时,系统通常会生成此访问令牌。
参数部分
- “添加参数”- 在参数表中添加新行,且类型为“获取或发布”。如果上一行未填充内容,则不能添加新行。
- “添加标头”- 在参数表中添加新行,且类型为“Http 标头”。如果上一行未填充内容,则不能添加新行。
备注:
如要为一个标头添加多个值,您须使用逗号(“
,”)连接这些值。 - “添加 URL 段”- 在参数表中添加新行,且类型为“URL 段”。如果上一行未填充内容,则不能添加新行。
- “删除”- 删除参数表中的选定行。如未选择行,则系统会禁用此按钮。
参数表
- “名称”- 参数、标头或 URL 段的名称。
- “值”- 参数、标头或 URL 段的值。
- “类型”- 行的类型。可用的选项如下:
- “获取或发布”- 指明行是可在请求中使用的参数。
- “Http 标头”- 指明在“参数”表中添加的行是在调用 API 时要发送的请求标头。
- UrlSegment - Indicates that the line added is a fragment or the URL provided in the End point field.
备注:
在某些情况下,系统可能会返回一个错误,表明不能存在重复参数。此类错误可能由需要包含“密码”和“用户名”参数的身份验证请求引发。若情况如此,建议使用“正文”属性进行传递。
附件部分
- “添加附件”- 用于通过创建新行,以将文件添加到所执行的 HTTP 请求中。仅在“请求方法”设为“
POST”或“PUT”时启用。 - Delete Attachment - Enables you to delete a previously added line, in the Attachments section.
- “名称”- 要附加的文件的名称。
- “文件路径”- 要附加的文件的完整路径。
- Type - Indicates what type of information you are sending. This field is automatically filled in with Attachment.Preview - Enables you to preview the HTTP request you built, and opens the Response tab.
响应选项卡
This tab enables you to preview the request that you want to include in your workflow. It can be accessed by selecting the Preview button in the HTTP Request wizard once you fill in all the fields and configure the request. Alternatively, you can also change the tab in the upper part of the wizard.

此页面包含以下部分:
- “请求信息”- 此部分会显示与已执行请求相关的详细信息,具体会显示请求 URL、方法以及状态码。
- “预览响应”- 显示网页服务器的响应。
- “原始正文”- 以原始格式显示网页服务器的响应。
- “响应信息”- 显示有关网页服务器响应的详细信息,具体会显示响应状态和代码,以及受支持的内容类型标头。
- “下载资源”- 用于将所请求的资源下载到指定文件。
- “刷新”- 用于再次执行请求。
属性面板
客户端证书身份验证
- ClientCertificate - The location in which the Client Certificate file is stored. The full path must be provided. The supported certificate encoding is
X.509and the supported extensions are.pfxand.p12. It supports two-way handshake verification. - ClientCertificatePassword - The password that corresponds to the Client Certificate file you are using.
- Enable SSL certificate verification - Verify SSL certificates when sending a request. Verification failures will result in the request being aborted. This field only supports Boolean values (True, False).
- SecureClientCertificatePassword - The password for the specified Client Certificate file, in the form of a secure string. This field supports only SecureString variables.
常见
- ContinueOnError - Specifies if the automation should continue even when the activity throws an error. This field only supports Boolean values (True, False). The default value is False. As a result, if the field is blank and an error is thrown, the execution of the project stops. If the value is set to True, the execution of the project continues regardless of any error.
备注:
如果“Try Catch 异常处理”中包含该活动且“出错时继续”属性的值为“True”,则系统在执行项目时不会捕获任何错误。
- “显示名称”- 活动的显示名称。
- “超时(毫秒)”- 指定最长等待时间(以毫秒为单位),如果超出该时间后活动并未运行,系统便会抛出错误。默认值为 6000 毫秒(6 秒)。
输入
- AcceptFormat - The format in which to receive the web server's response. The following options are supported: ANY - the default value, XML, JSON, and CUSTOM. When choosing the CUSTOM AcceptFormat, if an
AcceptoracceptHeader parameter is present, then it will be sent as the custom accept format. If no header parameter is set,acceptwill get the RestSharp default value:application/json, aboveapplication/xml, text/json, text/x-json, text/javascript, text/xml. - “请求方法”- 调用 API 时使用的请求方法。支持以下 HTTP 动词:“
GET”、“POST”、“PUT”、“DELETE”、“HEAD”、“OPTIONS”、“PATCH”和“MERGE”。系统会默认选择“GET”方法。备注:HTTP 请求仅适用于 RestSharp 包版本 106.11.2 或更低版本。安装 RestSharp 版本 106.11.4 或更高版本时,它将返回错误。
- Request URL - The URL to which you want to make the request. Custom segments have to be placed between braces "{}" and defined in the Parameters section. For example, this URL
https://platform.uipath.com/odata/Robots(28)can be written ashttps://platform.uipath.com/odata/Robots{id}, and the value of theidparameter can be provided in the URLSegments window.
其他
- “私有”- 选中后将不再以“Verbose”级别记录变量和参数的值。
OAuth1
- “使用者密钥”- 要使用的使用者密钥(如果请求的 API 是基于 OAuth1 身份验证协议)。
- “使用者密码”- 要使用的使用者密码(如果请求的 API 是基于 OAuth1 身份验证协议)。
- “OAuth1 令牌”- 在批准使用者的授权请求后要使用的访问令牌(如果请求的 API 是基于 OAuth1 身份验证协议)。
- “OAuth1 令牌密码”- 在批准使用者的授权请求后要使用的密码(如果请求的 API 是基于 OAuth1 身份验证协议)。
OAuth2
- “OAuth2 令牌”- 要使用的访问令牌(如果请求的 API 是基于 OAuth2 身份验证协议)。在响应指定 API 的另一个 HTTP 请求时,系统通常会生成此访问令牌。
选项
- Attachments - Enables you to attach files to requests. Select the Ellipsis button to open the Attachments window and add all the required files.
- “正文”- 请求的正文。
- “正文格式”- 正文必须采用的格式。该选项默认用“
application/xml”填充。该字段支持字符串和字符串变量。 - Cookies - The cookies in the HTTP Request. Select the Ellipsis button to open the Cookies window.
- File attachments - List of attachments for the request.
- Filename for response attachment - The filename to be used for the file returned by the request.
- Headers - Enables you to include custom headers in the HTTP request. Select the Ellipsis button to open the Headers window.
- Parameters - The request parameters. Select the Ellipsis button to open the Parameters window, which corresponds to the Parameters section.
- UrlSegments - Custom segments added to the Endpoint URL between braces "{}". Select the Ellipsis button to open the URLSegments window. For example, the
https://platform.uipath.com/odata/Robots(28)URL can be written ashttps://platform.uipath.com/odata/Robots{id}, and the value of theidparameter can be provided in the URLSegments window. This field supports strings and string variables.
输出
- Headers - The response received from the HTTP request.
- Response attachment - The attachment saved from the response.
- Response content - The response received from the HTTP request, as a string variable.
- Response status - The status code received from the HTTP request, as an integer variable.
简单身份验证
- “密码”- 指明网页服务使用简单身份验证,并且允许输入密码。您还需添加用户名。该属性支持字符串和字符串变量。
- SecurePassword - Indicates that the web service uses secure authentication and enables you to input your secure string password. Adding a username is also required. This property supports secure string variables.
- “用户名”- 指明网页服务使用简单身份验证,并且允许输入用户名。您还需添加密码。该属性支持字符串和字符串变量。
跨平台配置
- “请求方法”- 调用 API 时使用的请求方法。支持以下 HTTP 动词:“
GET”、“POST”、“PUT”、“DELETE”、“HEAD”、“OPTIONS”、“PATCH”和“MERGE”。系统会默认选择“GET”方法。 - Request URL - The URL to which you want to make the request. Custom segments have to be placed between braces "{}" and defined in the Parameters section. For example, this URL
https://platform.uipath.com/odata/Robots(28)can be written ashttps://platform.uipath.com/odata/Robots{id}, and the value of theidparameter can be provided in the URLSegments window. - Parameters - The request parameters. Select the field to open the Dictionary window.
- Headers - Enables you to include custom headers in the HTTP request. Select the field to open the Dictionary window.
- “正文”- 请求的正文。
- “身份验证”- 指定调用 API 时要使用的身份验证协议。支持的协议如下:
- “无”- 默认选项。如果要向其发送请求的网页服务器不需要身份验证协议,则应使用此选项。
- “简单 Http”- 如果请求的 API 使用简单的 HTTP 身份验证协议,则必须选择此选项。选中后,系统会显示另外两个字段:“用户名”和“密码”。这两个字段必须使用指定 API 的有效凭据进行填充。
- OAuth1 - This option has to be selected if the API you are making requests to uses an OAuth1 protocol. If chosen, four additional fields are displayed: Consumer Key, Consumer Secret, Access Token, Access Token Secret.
- “OAuth2”- 如果请求的 API 使用 OAuth2 协议,则必须选择此选项。选中后,系统会显示“访问令牌”字段。在响应指定 API 的另一个 HTTP 请求时,系统通常会生成此访问令牌。
- Client Certificate - This option has to be selected if a client certificate is needed to complete the API call. If chosen, two additional fields are displayed:
- ClientCertificate - The location in which the Client Certificate file is stored. The full path must be provided. The supported certificate encoding is
X.509and the supported extensions are.pfxand.p12. It supports two-way handshake verification. - ClientCertificatePassword - The password that corresponds to the Client Certificate file you are using.
- ClientCertificate - The location in which the Client Certificate file is stored. The full path must be provided. The supported certificate encoding is
高级
选项
- “超时(毫秒)”- 指定最长等待时间(以毫秒为单位),如果超出该时间后活动并未运行,系统便会抛出错误。默认值为 6000 毫秒(6 秒)。
- Continue On Error - Specifies if the automation should continue even when the activity throws an error. This field only supports Boolean values (True, False). The default value is False. As a result, if the field is not configured and an error is thrown, the execution of the project stops. If the value is set to True, the execution of the project continues regardless of any error.
- SSL certificate verification - If selected, verifies SSL certificates when sending a request. Verification failures will result in the request being aborted.
- Accept Format - The format in which to receive the web server's response. The following options are supported: ANY - the default value, XML, JSON, and CUSTOM. When choosing the CUSTOM AcceptFormat, if an
AcceptoracceptHeader parameter is present, then it will be sent as the custom accept format. If no header parameter is set,acceptwill get the RestSharp default value:application/json, application/xml, text/json, text/x-json, text/javascript, text/xmlapplication/json, application/xml, text/json, text/x-json, text/javascript, text/xml - File Attachments - List of attachments for the request.
- Filename for response attachment - The filename to be used for the file returned by the request.
- “正文格式”- 正文必须采用的格式。该选项默认用“
application/xml”填充。该字段支持字符串和字符串变量。 - Cookies - The cookies in the HTTP Request. Select the field to open the Dictionary window.
- URL Segments - Custom segments added to the Endpoint URL between braces "{}". Select the field to open the Dictionary window. For example, the
https://platform.uipath.com/odata/Robots(28)URL can be written ashttps://platform.uipath.com/odata/Robots{id}, and the value of theidparameter can be provided in the Dictionary window. This field supports strings and string variables.
输出
- Response content - The response received from the HTTP request, as a string variable.
- Response status - The status code received from the HTTP request, as an integer variable.
- Response headers - The response received from the HTTP request.
- Response attachment - The attachment saved from the response.