> For the complete documentation index, see [llms.txt](https://docs.parallels.com/landing/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.parallels.com/landing/ras-admin-guide/v22-ja-jp/parallels-ras-no-api/ras-rest-api/roguinoyobirikuesutono.md).

# ログインおよびリクエストの送信

このセクションでは、RAS REST API の使用例を紹介しており、すぐに使い始めるのに役立ちます。この例では、以下の方法について説明しています：

1. Parallels RAS にログインし、セッショントークンを取得してください。
2. 利用可能なすべてのリモート デスクトップ セッション ホストに関する情報を取得します。
3. 特定のリモート デスクトップ セッション ホストに関する情報を取得します。
4. リモート デスクトップ セッション ホストのプロパティを変更します。

### **Parallels RAS にログオンし、セッショントークンを取得します**

リソースにアクセスするには、まず管理者アカウントでParallels RASにログインし、セッショントークンを取得する必要があります。これを行うには、次のリクエストを送信します。

`POST https://<API-host>/api/session/logon`

\*\*リクエストヘッダー：\*\*ログインリクエストには、Content-Type リクエストヘッダーのみを含める必要があります。その後のリクエストには、この後の例で示すように、auth\_token ヘッダーも追加で含める必要があります。

**Content-Type:** application/json; api-version=1.0

\*\*要求本文：\*\*要求本文には、RAS 管理者のユーザー名とパスワードを含める必要があります。

```
{
 "username": "USER",
 "password": "PASSWORD"
}
```

\*\*回答：\*\*ログイン要求を送信すると、セッショントークンが含まれた応答が返されます。このトークンは、その後のすべてのリクエストで使用します：

```
{
 "authToken": "Lj+KddoJkANhzvbDRvB=K=DFCroRjXJHeeWGbGlIRKaz-EXplbmhVWvWTiDVqtOq"
}
```

### **リモート デスクトップ セッション ホストに関する情報を取得する**

セッショントークンを取得したので、さまざまなリソースにアクセスするためのリクエストを送信できるようになりました。この例では、まず利用可能なすべてのリモート デスクトップ セッション ホストに関する情報を取得します。次の例では、特定のリモート デスクトップ セッション ホストに関する情報を取得します。

リモート デスクトップ セッション ホストの情報を取得するには、次のリクエストを送信してください：

`GET https://<API-host>/api/RDS/Host`

\*\*要求ヘッダー：\*\*今回は、セキュリティ トークン リクエストヘッダーも必ず含む必要があり、その値には先ほど取得したセッショントークンを指定する必要があります。

**Content-Type:** application/json; api-version=1.0

**auth\_token:** Lj+KddoJkANhzvbDRvB=K=DFCroRjXJHeeWGbGlIRKaz-EXplbmhVWvWTiDVqtOq

\*\*応答：\*\*応答は次のような形式になります（ファーム内に複数のリモート デスクトップ セッション ホストが存在する場合、結果セットの各ブロックレベル要素には個々のサーバーに関する情報が含まれます）。

```
[
    {
        "directAddress": "IP_ADDR",
        "rasTemplateId": 0,
        "inheritDefaultAgentSettings": true,
        "inheritDefaultPrinterSettings": true,
        "inheritDefaultUPDSettings": true,
        "inheritDefaultDesktopAccessSettings": true,
        "port": 3389,
        
        "restrictDesktopAccess": false,
        "restrictedUsers": [],
        "server": "IP_ADDR",
        "enabled": true,
        "description": "",
        "siteId": 1,
        "id": 2
    }
]
```

### **特定のリモート デスクトップ セッション ホストに関する情報を取得する**

特定のサーバーに関する情報を取得するには、上記と同じ HTTP 要求を使用しますが、最後にサーバー ID を追加します：

`GET https://<API-host>/api/RDS/Host/2/`

応答も上記の例と同様となり、指定されたサーバーに関する情報のみが含まれます。

### **リモート デスクトップ セッション ホストのプロパティを変更する**

この例では、先ほど取得したリモート デスクトップ セッション ホストのプロパティを変更します。簡単にするために、「description」フィールドを変更してみましょう。

リモート デスクトップ セッション ホストのプロパティを変更するリクエストの構文は次のとおりです。

`PUT https://<API-host>/api/RDS/Host/2/`

リクエストの末尾`2`にある に注意してください。これは、変更対象とするリモート デスクトップ セッション ホストの ID を指定しています。

**要求ヘッダー：**

* **Content-Type**: application/json; api-version=1.0
* **auth\_token**: Lj+KddoJkANhzvbDRvB=K=DFCroRjXJHeeWGbGlIRKaz-EXplbmhVWvWTiDVqtOq

**HTTP 要求本文：**

```
{
    "description": "description was updated!"
}
```

\*\*応答：\*\*リクエスト`PUT`が成功した場合、コード を含む空の応答が返されます`204: No Content`。「description」フィールドが実際に変更されたことを確認するために、先ほど使用したのと同じ GET リクエストを使ってみましょう： `GET https://<API-host>/api/RDS/Host`

ご覧のとおり、結果には更新された「description」フィールドが含まれています：

```
[
    {
        "directAddress": "IP_ADDR",
        "rasTemplateId": 0,
        "inheritDefaultAgentSettings": true,
        
        "server": "IP_ADDR",
        "enabled": true,
        "description": "description was updated!",
        "siteId": 1,
        "id": 2
    }
]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.parallels.com/landing/ras-admin-guide/v22-ja-jp/parallels-ras-no-api/ras-rest-api/roguinoyobirikuesutono.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
