跳转到主要内容
包含 application/x-www-form-urlencoded、文本和二进制数据的 HTTP 请求。

属性

名称类型说明
Urlstring资源 URL。
Methodstring请求类型(如 GET 或 POST)。
AuthTokenstring身份验证令牌(若需要外部服务身份验证)。
AuthSchemestring身份验证方案。
ThrowExceptionOnFailedboolean指定当外部服务返回错误代码作为 HTTP 响应状态(即不在 200–299 范围内)时,是否应抛出异常。若设为 False,当外部服务返回错误代码作为 HTTP 响应状态时不会抛出异常。要查看 HTTP 响应状态码,请检查 Status 属性的值。默认设为 True。重要!如果响应包含错误代码,表示外部服务处于正常工作状态,且会对请求进行响应。若在发送 HTTP 请求时发生与服务可用性或网络连接状态相关的错误,无论此属性的值为何,程序都会抛出异常,因为此时并不会提供外部服务的 HTTP 状态码。
Timeoutnumber请求超时时间(分钟)。默认设为 1 分钟。重要!请求超时设置不得大于脚本运行时限制(600 秒)。
ResponseTextstring, 唯讀文本格式的响应结果。
ResponseTypestring, 唯讀服务返回的响应内容类型,例如 “application/json”。
Statusnumber外部服务的 HTTP 响应状态码。若 ThrowExceptionOnFailed 设为 True,错误代码将抛出异常并中断处理事务。错误消息文本可在 Skill Monitor 中查看。

方法

NameDescription
SetHeader(string name, string value);为请求设置额外的 HTTP 头。应针对每个头名称分别调用此方法。
Send();发送 HTTP 请求。
SetFileContent(DocumentExportResult documentExportResult, string mediaType?);初始化基于流程的 HTTP 请求,允许将导出数据作为文件传递。传递内容类型会根据导出文件的扩展名自动设置,例如 application/json、application/pdf。如有需要,可使用可选参数 mediaType 预先设置内容类型。
SetFileContent(BinaryFile binaryFile, string mediaType?);初始化基于二进制数据的 HTTP 请求,可传递在创建处理事务时导入的源图像文件,或类型为 Picture 的 field 中包含的图像。传递内容类型会根据导入文件的扩展名自动设置。如有需要,可使用可选参数 mediaType 预先设置内容类型。
SetSourceFileContent(string mediaType?);初始化基于二进制数据的 HTTP 请求,允许传递在创建处理事务时导入的源图像文件。传递内容类型会根据导入文件的扩展名自动设置。如有需要,可使用可选参数 mediaType 预先设置内容类型。**重要提示:**此方法已弃用。它只能访问该处理事务中的第一个文件。应改用 SetFileContent() 方法。
SetStringContent(string content, ContentEncoding contentEncoding?, string mediaType?);初始化基于 string 的 HTTP 请求。默认情况下,Content-Type 设置为 application/json,字符编码为 UTF-8。如有需要,您可以更改内容类型和编码。
SetUrlFormEncodedContent(any content);为基于 JavaScript 对象的请求初始化内容,并将其按 application/x-www-form-urlencoded 编码。应将 JavaScript 对象初始化为一组简单的属性值,例如:var form = {}; form.grant_type = "password"; form.scope = "openid permissions"; form.client_id = "value of client_id"; form.client_secret = "value of client_secret"; form.password = "Password"; form.username = "User Name"; request.SetUrlFormEncodedContent(form);