Connection
ワークフロー、アプリ、インポートスクリプトからターゲットサイトにリクエストを送信する HTTP 接続を表します。
Properties
名前 | タイプ | 説明 |
|---|---|---|
ヘッダー | Array。<{ 名前: 文字列、値: 文字列 }> | The headers added to the connection. |
URL | 文字列 | The base URL of the target site. If empty, specify an absolute URL in each request method. |
コンストラクター
Connection
Creates a connection to a target site.
パラメーター
名前 | タイプ | 説明 |
|---|---|---|
URL | 文字列 | The base URL of the target site. If empty, specify an absolute URL in each request method. |
sslKeyName | 文字列 | The optional name of the SSL key used to establish a secure connection. To omit this parameter, pass |
タイムアウト | 整数 | The optional timeout, in milliseconds, for outgoing HTTP requests. |
関連事項
Quick Example
Request Styles
スタイル | メソッド | 振る舞い |
|---|---|---|
同期 | The request completes during the current execution and returns a Response 。 | |
非同期 | The request runs after the current transaction commits. YouTrack passes the response to a named async function. |
メソッド
addHeader
Adds a header to the connection. The value parameter can also reference a secret stored in the settings for a YouTrack app.
- パラメーター
名前
タイプ
説明
ヘッダー
オブジェクト、文字列
A header object with the structure
{name: string, value: string}.When the
valueparameter is specified separately, this string is used as the header name.値
文字列
The value to assign to the header. This parameter is used only when
headeris a string.- 戻り値
タイプ
説明
接続
The current Connection object.
basicAuth
Adds a Basic authorization header generated from the specified login and password. The password parameter can also reference a secret stored in the settings for a YouTrack app.
- パラメーター
名前
タイプ
説明
ログイン
文字列
The login for Basic authentication.
パスワード
文字列
The password for Basic authentication.
- 戻り値
タイプ
説明
接続
The current Connection object.
bearerAuth
Adds a Bearer authorization header for the specified token. The token parameter can also reference a secret stored in the settings for a YouTrack app.
- パラメーター
名前
タイプ
説明
トークン
文字列
The token for Bearer authentication.
- 戻り値
タイプ
説明
接続
The current Connection object.
connectSync
同期 CONNECT 要求を実行します。
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
The complete URL combines the URL passed to the Connection constructor with this string.
If the constructor URL is empty, specify the absolute URL of the target site.
クエリパラメーター
Array。<{ 名前: 文字列、値: 文字列 }>、オブジェクト
クエリパラメーター。
If an object is passed, its keys are considered to be parameter names.
- 戻り値
タイプ
説明
The HTTP response.
deleteAsync
非同期の DELETE リクエストをスケジュールします。
2026.2 から利用可能
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
クエリパラメーター
配列、オブジェクト
クエリパラメーター。
ハンドラー名
文字列
The name of the async function that handles the response.
deleteSync
同期 DELETE 要求を実行します。
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
The complete URL combines the URL passed to the Connection constructor with this string.
If the constructor URL is empty, specify the absolute URL of the target site.
クエリパラメーター
Array。<{ 名前: 文字列、値: 文字列 }>、オブジェクト
クエリパラメーター。
If an object is passed, its keys are considered to be parameter names.
- 戻り値
タイプ
説明
The HTTP response.
doAsync
Schedules an asynchronous HTTP request. The request is executed after the current transaction commits, and the response is passed to the named async function handler. The handler must be declared in the asyncFunctions property of the rule or HTTP handler. Inside the handler, the response is available as the response property of the context object. It provides the same properties and methods as Response 。
2026.2 から利用可能
- パラメーター
名前
タイプ
説明
リクエストタイプ
文字列
有効な HTTP リクエストタイプ。
ウリ
文字列
相対 URI。
クエリパラメーター
Array。<{ 名前: 文字列、値: 文字列 }>、オブジェクト
クエリパラメーター。
ペイロード
文字列、オブジェクト
The content to send in the request.
ハンドラー名
文字列
The name of the async function that handles the response.
doSync
Sends a synchronous HTTP request of the specified type. For common request types, you can call a dedicated method such as getSync() or postSync() instead.
- パラメーター
名前
タイプ
説明
リクエストタイプ
文字列
有効な HTTP リクエストタイプ。
For a list of supported request types, see REQUEST_TYPES 。
ウリ
文字列
相対 URI。
The complete URL combines the URL passed to the Connection constructor with this string.
If the constructor URL is empty, specify the absolute URL of the target site.
クエリパラメーター
Array。<{ 名前: 文字列、値: 文字列 }>
クエリパラメーター。
ペイロード
文字列、配列、オブジェクト
The content to send in the request.
- 戻り値
タイプ
説明
The HTTP response.
getAsync
非同期 GET リクエストをスケジュールします。
2026.2 から利用可能
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
クエリパラメーター
配列、オブジェクト
クエリパラメーター。
ハンドラー名
文字列
The name of the async function that handles the response.
getSync
同期 GET リクエストを実行します。
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
The complete URL combines the URL passed to the Connection constructor with this string.
If the constructor URL is empty, specify the absolute URL of the target site.
クエリパラメーター
Array。<{ 名前: 文字列、値: 文字列 }>、オブジェクト
クエリパラメーター。
If an object is passed, its keys are considered to be parameter names.
- 戻り値
タイプ
説明
The HTTP response.
headSync
同期 HEAD リクエストを実行します。
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
The complete URL combines the URL passed to the Connection constructor with this string.
If the constructor URL is empty, specify the absolute URL of the target site.
クエリパラメーター
Array。<{ 名前: 文字列、値: 文字列 }>、オブジェクト
クエリパラメーター。
If an object is passed, its keys are considered to be parameter names.
- 戻り値
タイプ
説明
The HTTP response.
optionsSync
同期 OPTIONS 要求を実行します。
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
The complete URL combines the URL passed to the Connection constructor with this string.
If the constructor URL is empty, specify the absolute URL of the target site.
クエリパラメーター
Array。<{ 名前: 文字列、値: 文字列 }>、オブジェクト
クエリパラメーター。
If an object is passed, its keys are considered to be parameter names.
- 戻り値
タイプ
説明
The HTTP response.
patchAsync
非同期の PATCH リクエストをスケジュールします。
2026.2 から利用可能
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
クエリパラメーター
配列、オブジェクト
クエリパラメーター。
ペイロード
文字列、オブジェクト
The content to send in the request.
ハンドラー名
文字列
The name of the async function that handles the response.
patchSync
同期 PATCH 要求を実行します。
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
The complete URL combines the URL passed to the Connection constructor with this string.
If the constructor URL is empty, specify the absolute URL of the target site.
クエリパラメーター
Array。<{ 名前: 文字列、値: 文字列 }>、オブジェクト
クエリパラメーター。
If an object is passed, its keys are considered to be parameter names.
ペイロード
文字列
The content to send in the request.
- 戻り値
タイプ
説明
The HTTP response.
postAsync
非同期 POST リクエストをスケジュールします。
2026.2 から利用可能
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
クエリパラメーター
配列、オブジェクト
クエリパラメーター。
ペイロード
文字列、オブジェクト
The content to send in the request.
ハンドラー名
文字列
The name of the async function that handles the response.
postSync
同期 POST 要求を実行します。
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
The complete URL combines the URL passed to the Connection constructor with this string.
If the constructor URL is empty, specify the absolute URL of the target site.
クエリパラメーター
Array。<{ 名前: 文字列、値: 文字列 }>、オブジェクト
クエリパラメーター。
If an object is passed, its keys are considered to be parameter names.
If the payload parameter is empty, the query parameters are passed as a form entity.
ペイロード
文字列、オブジェクト
The content to send in the request.
For posting attachment files from YouTrack to a third-party application, pass the payload as an object, set its
typevalue tomultipart/form-data, and pass the attachments inparts.For each part,
name、size、fileName、contentvalues are required.For details and an example, see multipart/form-data タイプのバイナリコンテンツの投稿。
- 戻り値
タイプ
説明
The HTTP response.
- サンプル
- const attachment = issue.attachments.first(); connection.postSync('issues/' + issue.id + '/attachments', [], { type: 'multipart/form-data', parts: [ { // These four fields are required for each part. // Optionally, you can also set the `contentType` value individually for each part. name: 'my-part-name', size: attachment.size, fileName: 'filename', content: attachment.content } ] });
putAsync
非同期 PUT リクエストをスケジュールします。
2026.2 から利用可能
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
クエリパラメーター
配列、オブジェクト
クエリパラメーター。
ペイロード
文字列、オブジェクト
The content to send in the request.
ハンドラー名
文字列
The name of the async function that handles the response.
putSync
同期 PUT 要求を実行します。
- パラメーター
名前
タイプ
説明
ウリ
文字列
リクエスト URI。
The complete URL combines the URL passed to the Connection constructor with this string.
If the constructor URL is empty, specify the absolute URL of the target site.
クエリパラメーター
Array。<{ 名前: 文字列、値: 文字列 }>、オブジェクト
クエリパラメーター。
If an object is passed, its keys are considered to be parameter names.
If the payload parameter is empty, the query parameters are passed as a form entity.
ペイロード
文字列
The content to send in the request.
- 戻り値
タイプ
説明
The HTTP response.
setHeader
Sets a header to the current connection. If the specified header already exists, its value is updated. The value parameter can also contain references to secrets stored in the settings for a YouTrack app.
- パラメーター
名前
タイプ
説明
ヘッダー
オブジェクト、文字列
A header object with the structure
{name: string, value: string}.If the
valueparameter is specified separately, the provided string is used as the name of the header.値
文字列
The value to assign to the header. This parameter is used only when
headeris a string.- 戻り値
タイプ
説明
接続
The current Connection object.