> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# httpPut

> 向 API 接口发出 HTTP PUT 请求，支持原始正文和表单数据负载。

向 API 接口发出 HTTP PUT 请求。

## 必需的参数

* **url**: 发出 PUT 请求的 URL。

## 可选的参数

* **authentication**: 用于设置手动生成的授权头，例如 bearer token。
* **authscheme**: 要使用的授权机制。仅当提供用户和密码时相关。允许的值为 `BASIC`、`DIGEST`、`NONE` 和 `NTLM`。默认值为 `BASIC`。
  * **user**: 如果 authscheme 参数设置为 `NONE` 以外的其它值，则使用该用户名进行身份验证。
  * **password**: 如果 authscheme 参数设置为 `NONE` 以外的其它值，则使用该密码进行身份验证。
* **charset**: 交换／传输的数据的字符集。默认值为 `UTF-8`。
* **client\_id**: 客户端 ID。仅限 OAuth 1.0。
* **client\_secret**: 客户密钥。仅限 OAuth 1.0。
* **contenttype**: POST 的内容类型。默认值为 `text/html`。
* **cookie:\***: 添加到请求中的 cookie。
* **firewall\_port**: 防火墙的端口号。
* **firewall\_server**: 防火墙的 IP 地址或主机名。
  * **firewall\_user**: 向防火墙进行身份验证的用户 ID。
  * **firewall\_password**: 向防火墙进行身份验证的密码。
* **firewall\_type**: 防火墙的类型。允许的值为 `NONE`、`TUNNEL`、`SOCKS4` 和 `SOCKS5`。默认值为 `NONE`。
* **followredirects**: 是否遵循 HTTP 重定向。允许的值为 `TRUE` 或 `FALSE`。默认值是 `TRUE`。
* **header:name#**: 与请求一起传递的每个自定义头的名称。
* **header:value#**: 与请求一起传递的每个自定义头的值。
* **httpversion**: HTTP 协议版本。允许的值为 `1.0` 或 `1.1`。默认值为 `1.1`。
* **internalconfig#**: 设置一个内部配置设置。
* **paramname#**: 与请求一起传递的每个参数的名称。
* **paramvalue#**: 与请求一起传递的每个参数的值。
* **proxy\_authscheme**: 代理服务器的认证方案。允许的值为 `BASIC`、`DIGEST`、`PROPRIETARY`、`NONE` 和 `NTLM`。默认值为 `BASIC`。
* **proxy\_authtoken**: 代理身份验证令牌。
* **proxy\_auto**: 是否从 Windows 系统设置中检测代理。这优先于其它代理设置，在 Java 中不可用。允许的值为 `TRUE` 或 `FALSE`。默认值为 `FALSE`。
* **proxy\_port**: 代理服务器的端口号。
* **proxy\_server**: 用于请求的代理服务器的 IP 地址或主机名。
  * **proxy\_user**: 向代理服务器进行身份验证的用户 ID。
  * **proxy\_password**: 与代理服务器进行身份验证的密码。
* **proxy\_ssltype**: 代理服务器的 TLS／SSL 类型。允许的值为 `AUTO`、`ALWAYS`、`NEVER` 和 `TUNNEL`。默认值为 `AUTO`。
* **putdata**: 要包含在 PUT 中的数据。使用 `file://`，后跟文件路径来发布文件的内容。
* **sign\_method**: 用于计算 OAuth 1.0 签名的签名方法。允许的值为 `HMAC-SHA1` 和 `PLAINTEXT`。默认值为 `HMAC-SHA1`。
* **sslcert**: 要从服务器接受的 TLS／SSL 证书。这可以采用完整 PEM 证书，包含证书的文件路径，公钥，MD5 指纹或 SHA-1 指纹的形式。 指定证书以外的任何证书都将被拒绝。 如果未指定，此值默认为 `TRUSTED`，这意味着仅接受系统信任的证书。 如果设置为 `*`，则接受任何证书。
* **sslclientcert**: 客户端证书的名称。
* **sslclientcertpassword**: 客户端证书的密码。
* **sslclientcertsubject**: 客户端证书的主题。使用星号会找到存储中的第一个证书。
* **sslclientcerttype**: 客户端证书的存储类型。允许的值为 `USER`、`MACHINE`、`PFXFILE`、`PFXBLOB`、`JKSFILE`、`JKSBLOB`、`PEMKEY\_FILE`、`PEMKEY\_BLOB`、`PUBLIC\_KEY\_FILE`、`PUBLIC\_KEY\_BLOB`、`SSHPUBLIC\_KEY\_BLOB`、`P7BFILE`、`P7BBLOB`、`SSHPUBLIC\_KEY\_FILE`、`PPKFILE`、`PPKBLOB`、`XMLFILE` 和 `XMLBLOB`。
* **timeout**: 操作完成的超时时间（以秒为单位）。零（0）表示没有超时。默认值为 `60`。
* **token**: OAuth 的请求令牌。
* **token\_secret**: 请求令牌密钥。仅限 OAuth 1.0。
* **version**: OAuth 版本。使用 OAuth 来授权请求。允许的值为 `Disabled`、`1.0` 和 `2.0`。默认值为 `Disabled`。

## 输出属性

* **cookie:\***: Cookie 随响应返回。
* **header:\***: 响应返回的头文件。
* **http:allcookies**: 响应中的所有 cookie，以单个字符串形式返回。
* **http:content**: HTTP 响应的内容。
* **http:statuscode**: 从请求返回的 HTTP 状态代码。
* **ssl:issuer**: TLS／SSL 证书的颁发者。
* **ssl:subject**: TLS／SSL 证书的主题。

## 示例

### 使用原始 PUT 主体

```xml theme={null}
<!-- Setting the url, putdata and content type of the request -->
<arc:set attr="http.URL" value="https://postman-echo.com/put" />
<arc:set attr="http.putdata" value="file://[FilePath]" />
<arc:set attr="http.contenttype" value="text/html" />
<!-- Adding an HTTP header to the PUT request -->
<arc:set attr="http.header:name#1" value="mySpecialHeader" />
<arc:set attr="http.header:value#1"value="Foo" />
<!-- Setting the credentials via basic authentication -->
<arc:set attr="http.user" value="postman" />
<arc:set attr="http.password" value="password" />
<!-- Optional logging parameter. Useful when troubleshooting a request -->
<arc:set attr="http.logfile" value="/tmp/httpLog.txt" />
<arc:set attr="http.verbosity" value="3" />

<!-- Passing in the http input item to the call and setting the data of the output file to be the HTTP response -->
<arc:call op="httpPut" in="http" out="response">
  <arc:set attr="output.data" value="[response.http:content]" />
</arc:call>

<!-- Setting the output filename and pushing the file out -->
<arc:set attr="output.filename" value="httpResponseContent.txt" />
<arc:push item="output" />
```

### 使用表单数据作为正文

```xml theme={null}
<!-- Setting the url, content type and form encoding of the request -->
<arc:set attr="http.URL" value="https://postman-echo.com/put" />
<arc:set attr="http.contenttype" value="application/x-www-form-urlencoded" />
<arc:set attr="http.formencoding" value="URLENCODED" />
<!-- Setting the form data via paramname/paramvalue -->
<arc:set attr="http.paramname#1" value="Fee" />
<arc:set attr="http.paramvalue#1" value="Fie" />
<arc:set attr="http.paramname#2" value="Foe" />
<arc:set attr="http.paramvalue#2" value="Fum" />
<!-- Adding an HTTP header to the PUT request -->
<arc:set attr="http.header:name#1" value="mySpecialHeader" />
<arc:set attr="http.header:value#1"value="Foo" />
<!-- Setting the credentials via basic authentication -->
<arc:set attr="http.user" value="postman" />
<arc:set attr="http.password" value="password" />
<!-- Optional logging parameter. Useful when troubleshooting a request -->
<arc:set attr="http.logfile" value="/tmp/httpLog.txt" />
<arc:set attr="http.verbosity" value="3" />

<!-- Passing in the http input item to the call and setting the data of the output file to be the HTTP response -->
<arc:call op="httpPut" in="http" out="response">
  <arc:set attr="output.data" value="[response.http:content]" />
</arc:call>

<!-- Setting the output filename and pushing the file out -->
<arc:set attr="output.filename" value="httpResponseContent.txt" />
<arc:push item="output" />
```
