YouTrack および Hub ヘルプの開発者ポータル

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

Connection(url, sslKeyName, timeout)

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 null .

タイムアウト

整数

The optional timeout, in milliseconds, for outgoing HTTP requests.

関連事項

Quick Example

// Gets the content of a PasteBin paste, assuming that we have received its key (`pasteBinKey`) in a prior request. const connection = new http.Connection('http://pastebin.com/raw/'); connection.addHeader({name: 'Content-Type', value: 'text/plain'}); const response = connection.getSync(pasteBinKey, ''); if (response && response.code === 200) { let text = ''; response.headers.forEach(function(header) { text += header.name + ': ' + header.value + '\n'; }); text += '\n' + response.response; issue.addComment(text); }

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

addHeader(header, value)

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 value parameter is specified separately, this string is used as the header name.

文字列

The value to assign to the header. This parameter is used only when header is a string.

戻り値

タイプ

説明

接続

The current Connection object.

basicAuth

basicAuth(login, password)

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

bearerAuth(token)

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

connectSync(uri, queryParams)

同期 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.

戻り値

タイプ

説明

Response

The HTTP response.

deleteAsync

deleteAsync(uri, queryParams, handlerName)

非同期の DELETE リクエストをスケジュールします。

2026.2 から利用可能

パラメーター

名前

タイプ

説明

ウリ

文字列

リクエスト URI。

クエリパラメーター

配列、オブジェクト

クエリパラメーター。

ハンドラー名

文字列

The name of the async function that handles the response.

deleteSync

deleteSync(uri, queryParams)

同期 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.

戻り値

タイプ

説明

Response

The HTTP response.

doAsync

doAsync(requestType, uri, queryParams, payload, handlerName)

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

doSync(requestType, uri, queryParams, payload)

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.

戻り値

タイプ

説明

Response

The HTTP response.

getAsync

getAsync(uri, queryParams, handlerName)

非同期 GET リクエストをスケジュールします。

2026.2 から利用可能

パラメーター

名前

タイプ

説明

ウリ

文字列

リクエスト URI。

クエリパラメーター

配列、オブジェクト

クエリパラメーター。

ハンドラー名

文字列

The name of the async function that handles the response.

getSync

getSync(uri, queryParams)

同期 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.

戻り値

タイプ

説明

Response

The HTTP response.

headSync

headSync(uri, queryParams)

同期 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.

戻り値

タイプ

説明

Response

The HTTP response.

optionsSync

optionsSync(uri, queryParams)

同期 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.

戻り値

タイプ

説明

Response

The HTTP response.

patchAsync

patchAsync(uri, queryParams, payload, handlerName)

非同期の PATCH リクエストをスケジュールします。

2026.2 から利用可能

パラメーター

名前

タイプ

説明

ウリ

文字列

リクエスト URI。

クエリパラメーター

配列、オブジェクト

クエリパラメーター。

ペイロード

文字列、オブジェクト

The content to send in the request.

ハンドラー名

文字列

The name of the async function that handles the response.

patchSync

patchSync(uri, queryParams, payload)

同期 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.

戻り値

タイプ

説明

Response

The HTTP response.

postAsync

postAsync(uri, queryParams, payload, handlerName)

非同期 POST リクエストをスケジュールします。

2026.2 から利用可能

パラメーター

名前

タイプ

説明

ウリ

文字列

リクエスト URI。

クエリパラメーター

配列、オブジェクト

クエリパラメーター。

ペイロード

文字列、オブジェクト

The content to send in the request.

ハンドラー名

文字列

The name of the async function that handles the response.

postSync

postSync(uri, queryParams, payload)

同期 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 type value to multipart/form-data , and pass the attachments in parts .

For each part, namesizefileNamecontent values are required.

For details and an example, see multipart/form-data タイプのバイナリコンテンツの投稿

戻り値

タイプ

説明

Response

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

putAsync(uri, queryParams, payload, handlerName)

非同期 PUT リクエストをスケジュールします。

2026.2 から利用可能

パラメーター

名前

タイプ

説明

ウリ

文字列

リクエスト URI。

クエリパラメーター

配列、オブジェクト

クエリパラメーター。

ペイロード

文字列、オブジェクト

The content to send in the request.

ハンドラー名

文字列

The name of the async function that handles the response.

putSync

putSync(uri, queryParams, payload)

同期 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.

戻り値

タイプ

説明

Response

The HTTP response.

setHeader

setHeader(header, value)

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 value parameter 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 header is a string.

戻り値

タイプ

説明

接続

The current Connection object.

2026 年 9 月 10 日