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

# HttpRequest

> HttpRequest オブジェクト — カスタム アクティビティ スクリプトから、application/x-www-form-urlencoded、テキスト、JSON、またはバイナリ形式の HTTP リクエストを外部サービスに送信します。

`HttpRequest` は、`application/x-www-form-urlencoded`、テキスト、またはバイナリ データを含む HTTP リクエストを外部サービスに送信します。

<div id="properties">
  ## プロパティ
</div>

| Name                       | Type    | Access    | Description                                                                |
| :------------------------- | :------ | :-------- | :------------------------------------------------------------------------- |
| **Url**                    | string  | 読み取り/書き込み | リソース URL。                                                                  |
| **Method**                 | string  | 読み取り/書き込み | リクエストの種類 (たとえば `GET` または `POST`) 。                                         |
| **AuthToken**              | string  | 読み取り/書き込み | 外部サービスで認証が必要な場合の認証トークン。                                                    |
| **AuthScheme**             | string  | 読み取り/書き込み | 認証スキーム。                                                                    |
| **ThrowExceptionOnFailed** | boolean | 読み取り/書き込み | `true` (既定値) の場合、200～299 の範囲外の HTTP レスポンスステータスコードで例外が発生します。以下の注記を参照してください。 |
| **Timeout**                | number  | 読み取り/書き込み | リクエストのタイムアウト時間 (分単位) 。既定値は 1 分です。                                          |
| **ResponseText**           | string  | 読み取り専用    | テキスト形式のレスポンス本文。                                                            |
| **ResponseType**           | string  | 読み取り専用    | レスポンスのコンテンツタイプ (たとえば `application/json`) 。                                 |
| **Status**                 | number  | 読み取り専用    | 外部サービスから返される HTTP レスポンスステータスコード。                                           |

<Note>
  `ThrowExceptionOnFailed` が `false` の場合、4xx/5xx のレスポンスでは例外は発生しません。HTTP ステータスコードは `Status` を確認してください。エラーコードのレスポンスは、外部サービスに到達できており、応答も返していることを意味します。一方、サービスの可用性や接続失敗に関するエラーでは、このプロパティの設定に関係なく常にプログラム例外が発生し、その場合は HTTP ステータスコードを取得できません。
</Note>

<Note>
  `ThrowExceptionOnFailed` が `true` で、レスポンスがエラーコードの場合、トランザクションは中断され、エラーメッセージが Skill Monitor に表示されます。
</Note>

<Warning>
  `Timeout` の値は、スクリプトのランタイム制限 (600 秒) を超えることはできません。
</Warning>

<div id="methods">
  ## メソッド
</div>

<div id="setheader">
  ### SetHeader
</div>

```javascript theme={null}
void SetHeader(string name, string value);
```

リクエストに追加の HTTP ヘッダーを設定します。ヘッダーごとにこのメソッドを呼び出してください。

<div id="send">
  ### Send
</div>

```javascript theme={null}
void Send();
```

HTTP リクエストを送信します。

<div id="setfilecontent">
  ### SetFileContent
</div>

```javascript theme={null}
void SetFileContent(DocumentExportResult documentExportResult, string mediaType?);
void SetFileContent(BinaryFile binaryFile, string mediaType?);
```

ファイルベースの HTTP リクエスト本文を初期化します。コンテンツタイプはファイル拡張子から判定されます (例: `application/json`、`application/pdf`) 。これを明示的に指定するには、`mediaType` を渡します。

* 1 つ目のオーバーロードは、エクスポートされたデータ (`Document.Exports` のデータ) をファイルとして送信します。
* 2 つ目のオーバーロードは、バイナリデータを送信します。これは、トランザクション作成時の元の画像、または型 **Picture** の field に含まれる画像のいずれかです。

<div id="setsourcefilecontent">
  ### SetSourceFileContent
</div>

```javascript theme={null}
void SetSourceFileContent(string mediaType?);
```

トランザクションの作成時にインポートされた元の画像を使用して、バイナリデータのリクエストを初期化します。コンテンツタイプはファイル拡張子から自動的に判別されます。必要に応じて、`mediaType` で上書きできます。

<Warning>
  `SetSourceFileContent` は非推奨です。トランザクション内の最初のファイルにしかアクセスできません。代わりに [`SetFileContent`](#setfilecontent) を使用してください。
</Warning>

<div id="setstringcontent">
  ### SetStringContent
</div>

```javascript theme={null}
void SetStringContent(string content, ContentEncoding contentEncoding?, string mediaType?);
```

string ベースの HTTP リクエスト本文を初期化します。既定では `Content-Type: application/json` と UTF-8 エンコーディングが使用されます。オプション パラメーターを使用して、いずれかを上書きできます。

<div id="seturlformencodedcontent">
  ### SetUrlFormEncodedContent
</div>

```javascript theme={null}
void SetUrlFormEncodedContent(any content);
```

JavaScript オブジェクトからリクエスト本文を初期化し、`application/x-www-form-urlencoded` としてエンコードします。オブジェクトは、単純なプロパティ/値のペアのセットにしてください:

```javascript theme={null}
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);
```

<div id="related-topics">
  ## 関連トピック
</div>

* [Context](/ja/vantage/documentation/skill-designer/process/custom-activity/context)
* [MultipartFormDataRequest](/ja/vantage/documentation/skill-designer/process/custom-activity/multi-part-form-data-request)
* [BinaryFile](/ja/vantage/documentation/skill-designer/process/custom-activity/binary-file)
* [DocumentExportResult](/ja/vantage/documentation/skill-designer/process/custom-activity/document-export-result)
* [ContentEncoding](/ja/vantage/documentation/skill-designer/process/custom-activity/content-encoding)
* [オブジェクトモデル](/ja/vantage/documentation/skill-designer/process/custom-activity/object-model)
