---
title: "ジョブAPIに切り替える"
slug: "switch-to-the-jobs-api"
abstract: "Entities APIを使用するM.TargetおよびM.JobDescriptionエンティティの取得、作成、更新、削除のコールを置き換える方法、そしてQuerying APIをJobs APIに置き換える方法。"
---
# ジョブAPIに切り替える

Entities APIやクエリAPIの代わりにジョブAPIを使うには、現在エンティティAPI /api/entitiesを使用しているM.TargetM.JobDescriptionエンティティの取得、作成、更新、削除の呼び出しをジョブAPI /api/jobsに置き換える必要があります。

> !注このウォークスルーを完了してコードを更新した後は、ジョブ [管理](https://doc.sitecore.com/ch/ja/developers/cloud-dev/manage-jobs.html "Manage jobs")の推奨手順に従うことができます。

以下の例は、skipとtakeクエリパラメータを用いたジョブAPIへの呼び出しを示しています。

GET /api/jobs/123/targets?skip=0&take=25&state=Pending

ジョブAPIに切り替えるにはコードを更新する必要があります。このウォークスルーでは以下の方法を説明します:

:::攻略

1.  [求人目標や職務記述書の求人情報を特定・更新する](https://doc.sitecore.com/ch/ja/developers/cloud-dev/switch-to-the-jobs-api.html#locate-and-update-calls-for-job-target-or-job-description-entities)
2.  [ジョブターゲットや職務記述エンティティを作成するコールを見つけて更新する](https://doc.sitecore.com/ch/ja/developers/cloud-dev/switch-to-the-jobs-api.html#locate-and-update-calls-that-create-a-job-target-or-job-description-entity)
3.  [ジョブターゲットエンティティを作成する](https://doc.sitecore.com/ch/ja/developers/cloud-dev/switch-to-the-jobs-api.html#create-a-job-target-entity)
4.  [求人目標や求人記述書を削除するコールを見つけて更新してください](https://doc.sitecore.com/ch/ja/developers/cloud-dev/switch-to-the-jobs-api.html#locate-and-update-calls-that-delete-job-targets-or-the-job-description):::

> !注ジョブAPIからの応答構造は、エンティティAPIおよびクエリングAPIのものと同じです。

## 求人目標や職務記述書の求人情報を特定・更新する

Entities APIを使ってジョブターゲットエンティティを取得するAPIコールを探すには、以下の例に示されているようなコールを検索してください。

GET /api/entities/{TARGET\_ID}

この呼び出しは以下の例に似た応答を返します。

HTTP status code 200

{
 "id": 31388,
 "identifier": "dLQk3EjdT46PvqdVeqXFgw",
 "cultures": 
 "en-US"
 ,
 "properties": {
 "Target.Location": "10607",
 "Target.StartedOn": "2024-10-22T18:\`31:01\`.9773702Z",
 "Target.CompletedOn": "2024-10-22T18:\`31:27\`.4345384Z",
 "Target.StateDescription": "File processed",
 "Target.Data": {
 "type": "Web",
 "href": "http://www.stylelabs.com/product/annotation-templates/400/Annotation report - PDF template.zip"
 },
 "Target.Scope": null,
 "Target.Priority": null,
 "Target.RetryCount": null,
 "Target.State": {
 "identifier": "Completed",
 "labels": {
 "en-US": "Completed"
 }
 },
 "Target.Condition": {
 "identifier": "Success",
 "labels": {
 "en-US": "Success"
 }
 },
 "Target.Type": {
 "identifier": "Fetch",
 "labels": {
 "en-US": "Fetch job"
 }
 },
 "Target.StatusData": {
 "code": "FileProcessed"
 },
 "Target.PriorityLevel": null
 },
 "relations": {
 "JobToTarget": {
 "href": "https://localhost:8180/api/entities/31388/relations/JobToTarget"
 }
 },
 "created\_by": {
 "href": "https://localhost:8180/api/entities/6",
 "title": "The user who created the entity"
 },
 "created\_on": "2024-10-22T18:\`31:01\`.879725Z",
 "modified\_by": {
 "href": "https://localhost:8180/api/entities/6",
 "title": "The user who last modified the entity"
 },
 "modified\_on": "2024-10-22T18:\`31:27\`.4733914Z",
 "entitydefinition": {
 "href": "https://localhost:8180/api/entitydefinitions/M.Target",
 "title": "The entity definition for this entity"
 },
 "copy": {
 "href": "https://localhost:8180/api/entities/31388/copy",
 "title": "Copy this entity"
 },
 "permissions": {
 "href": "https://localhost:8180/api/entities/31388/permissions",
 "title": "The permissions on this entity"
 },
 "lifecycle": {
 "href": "https://localhost:8180/api/entities/31388/lifecycle",
 "title": "The lifecycle action for this entity."
 },
 "saved\_selections": {
 "href": "https://localhost:8180/api/entities/31388/savedselections",
 "title": "The saved selections this entity belongs to"
 },
 "roles": {
 "href": "https://localhost:8180/api/entities/31388/roles",
 "title": "Roles for this entity"
 },
 "annotations": {
 "href": "https://localhost:8180/api/entities/31388/annotations",
 "title": "Annotations for this entity"
 },
 "is\_root\_taxonomy\_item": false,
 "is\_path\_root": false,
 "inherits\_security": true,
 "is\_system\_owned": false,
 "version": 3,
 "self": {
 "href": "https://localhost:8180/api/entities/31388"
 },
 "renditions": {}
}

これを以下に置き換えてください:

GET /api/jobs/{jobId}/targets

この呼び出しは以下の例に似た応答を返します。

HTTP status code 200

{
 "items": 
 {
 "id": 31388,
 "identifier": "dLQk3EjdT46PvqdVeqXFgw",
 "cultures": 
 "en-US"
 ,
 "properties": {
 "Target.Location": "10607",
 "Target.StartedOn": "2024-10-22T18:\`31:01\`.9773702Z",
 "Target.CompletedOn": "2024-10-22T18:\`31:27\`.4345384Z",
 "Target.StateDescription": "File processed",
 "Target.Data": {
 "type": "Web",
 "href": "http://www.stylelabs.com/product/annotation-templates/400/Annotation report - PDF template.zip"
 },
 "Target.Scope": null,
 "Target.Priority": null,
 "Target.RetryCount": null,
 "Target.State": {
 "identifier": "Completed",
 "labels": {
 "en-US": "Completed"
 }
 },
 "Target.Condition": {
 "identifier": "Success",
 "labels": {
 "en-US": "Success"
 }
 },
 "Target.Type": {
 "identifier": "Fetch",
 "labels": {
 "en-US": "Fetch job"
 }
 },
 "Target.StatusData": {
 "code": "FileProcessed"
 },
 "Target.PriorityLevel": null
 },
 "relations": {
 "JobToTarget": {
 "parent": {
 "href": "https://localhost:8180/api/entities/31380"
 },
 "inherits\_security": true,
 "self": {
 "href": "https://localhost:8180/api/entities/31388/relations/JobToTarget"
 }
 }
 },
 "created\_by": {
 "href": "https://localhost:8180/api/entities/6",
 "title": "The user who created the entity"
 },
 "created\_on": "2024-10-22T18:\`31:01\`.879725Z",
 "modified\_by": {
 "href": "https://localhost:8180/api/entities/6",
 "title": "The user who last modified the entity"
 },
 "modified\_on": "2024-10-22T18:\`31:27\`.4733914Z",
 "entitydefinition": {
 "href": "https://localhost:8180/api/entitydefinitions/M.Target",
 "title": "The entity definition for this entity"
 },
 "copy": {
 "href": "https://localhost:8180/api/entities/31388/copy",
 "title": "Copy this entity"
 },
 "permissions": {
 "href": "https://localhost:8180/api/entities/31388/permissions",
 "title": "The permissions on this entity"
 },
 "lifecycle": {
 "href": "https://localhost:8180/api/entities/31388/lifecycle",
 "title": "The lifecycle action for this entity."
 },
 "saved\_selections": {
 "href": "https://localhost:8180/api/entities/31388/savedselections",
 "title": "The saved selections this entity belongs to"
 },
 "roles": {
 "href": "https://localhost:8180/api/entities/31388/roles",
 "title": "Roles for this entity"
 },
 "annotations": {
 "href": "https://localhost:8180/api/entities/31388/annotations",
 "title": "Annotations for this entity"
 },
 "is\_root\_taxonomy\_item": false,
 "is\_path\_root": false,
 "inherits\_security": true,
 "is\_system\_owned": false,
 "version": 3,
 "self": {
 "href": "https://localhost:8180/api/entities/31388"
 },
 "renditions": {}
 }
 ,
 "total\_items": 1,
 "returned\_items": 1,
 "offset": 0,
 "self": {
 "href": "https://localhost:8180/api/jobs/31380/targets?skip=0&take=25",
 "title": "This collection"
 }
}

Entities APIを使って職務記述エンティティを取得するAPIコールを探すには、以下の例に示されているようなコールを検索してください。

GET /api/entities/{JOB\_DESCRIPTION\_ID}

この呼び出しは以下の例に似た応答を返します。

HTTP status code 200

{
 "id": 31382,
 "identifier": "2OjPPWkhQj-4tc2dUGlaog",
 "cultures": 
 "en-US"
 ,
 "properties": {
 "Job.Configuration": {
 "file\_id": 0,
 "asset\_id": 10607,
 "files": 
 {
 "type": "Web",
 "href": "http://www.stylelabs.com/product/annotation-templates/400/Annotation report - PDF template.zip"
 }
 ,
 "post\_fetch": ,
 "process\_only\_post\_fetch\_tasks": false,
 "key": "local-df77b7f3dfd040f3bb11805218077a0e"
 },
 "Job.Data": {
 "qbtMDX\_JSAmNzJcIaMJxFA": {
 "Id": 31391,
 "has\_completed": true
 }
 }
 },
 "relations": {
 "JobToJobDescription": {
 "parent": {
 "href": "https://localhost:8180/api/entities/31380"
 },
 "inherits\_security": true,
 "self": {
 "href": "https://localhost:8180/api/entities/31382/relations/JobToJobDescription"
 }
 }
 },
 "created\_by": {
 "href": "https://localhost:8180/api/entities/6",
 "title": "The user who created the entity"
 },
 "created\_on": "2024-10-22T18:\`30:37\`.442564Z",
 "modified\_by": {
 "href": "https://localhost:8180/api/entities/6",
 "title": "The user who last modified the entity"
 },
 "modified\_on": "2024-10-22T18:\`31:27\`.135262Z",
 "entitydefinition": {
 "href": "https://localhost:8180/api/entitydefinitions/M.JobDescription",
 "title": "The entity definition for this entity"
 },
 "copy": {
 "href": "https://localhost:8180/api/entities/31382/copy",
 "title": "Copy this entity"
 },
 "permissions": {
 "href": "https://localhost:8180/api/entities/31382/permissions",
 "title": "The permissions on this entity"
 },
 "lifecycle": {
 "href": "https://localhost:8180/api/entities/31382/lifecycle",
 "title": "The lifecycle action for this entity."
 },
 "saved\_selections": {
 "href": "https://localhost:8180/api/entities/31382/savedselections",
 "title": "The saved selections this entity belongs to"
 },
 "roles": {
 "href": "https://localhost:8180/api/entities/31382/roles",
 "title": "Roles for this entity"
 },
 "annotations": {
 "href": "https://localhost:8180/api/entities/31382/annotations",
 "title": "Annotations for this entity"
 },
 "is\_root\_taxonomy\_item": false,
 "is\_path\_root": false,
 "inherits\_security": true,
 "is\_system\_owned": false,
 "version": 3,
 "self": {
 "href": "https://localhost:8180/api/entities/31382"
 },
 "renditions": {}
}

これを以下に置き換えてください:

GET /api/jobs/{jobId}/description

この呼び出しは以下の例に似た応答を返します。

HTTP status code 200

{
 "id": 31382,
 "identifier": "2OjPPWkhQj-4tc2dUGlaog",
 "cultures": 
 "en-US"
 ,
 "properties": {
 "Job.Configuration": {
 "file\_id": 0,
 "asset\_id": 10607,
 "files": 
 {
 "type": "Web",
 "href": "http://www.stylelabs.com/product/annotation-templates/400/Annotation report - PDF template.zip"
 }
 ,
 "post\_fetch": ,
 "process\_only\_post\_fetch\_tasks": false,
 "key": "local-df77b7f3dfd040f3bb11805218077a0e"
 },
 "Job.Data": {
 "qbtMDX\_JSAmNzJcIaMJxFA": {
 "Id": 31391,
 "has\_completed": true
 }
 }
 },
 "relations": {
 "JobToJobDescription": {
 "parent": {
 "href": "https://localhost:8180/api/entities/31380"
 },
 "inherits\_security": true,
 "self": {
 "href": "https://localhost:8180/api/entities/31382/relations/JobToJobDescription"
 }
 }
 },
 "created\_by": {
 "href": "https://localhost:8180/api/entities/6",
 "title": "The user who created the entity"
 },
 "created\_on": "2024-10-22T18:\`30:37\`.442564Z",
 "modified\_by": {
 "href": "https://localhost:8180/api/entities/6",
 "title": "The user who last modified the entity"
 },
 "modified\_on": "2024-10-22T18:\`31:27\`.135262Z",
 "entitydefinition": {
 "href": "https://localhost:8180/api/entitydefinitions/M.JobDescription",
 "title": "The entity definition for this entity"
 },
 "copy": {
 "href": "https://localhost:8180/api/entities/31382/copy",
 "title": "Copy this entity"
 },
 "permissions": {
 "href": "https://localhost:8180/api/entities/31382/permissions",
 "title": "The permissions on this entity"
 },
 "lifecycle": {
 "href": "https://localhost:8180/api/entities/31382/lifecycle",
 "title": "The lifecycle action for this entity."
 },
 "saved\_selections": {
 "href": "https://localhost:8180/api/entities/31382/savedselections",
 "title": "The saved selections this entity belongs to"
 },
 "roles": {
 "href": "https://localhost:8180/api/entities/31382/roles",
 "title": "Roles for this entity"
 },
 "annotations": {
 "href": "https://localhost:8180/api/entities/31382/annotations",
 "title": "Annotations for this entity"
 },
 "is\_root\_taxonomy\_item": false,
 "is\_path\_root": false,
 "inherits\_security": true,
 "is\_system\_owned": false,
 "version": 3,
 "self": {
 "href": "https://localhost:8180/api/entities/31382"
 },
 "renditions": {}
}

## ジョブターゲットや職務記述エンティティを作成するコールを見つけて更新する

Entities APIを使用する呼び出しをJobs APIを使う呼び出しに置き換える際は、古いAPI呼び出しで使われたリクエストボディが新しいAPIコールに正しくマッピングされていることを確認してください。新しいエンドポイントは以下のリクエストボディを期待します:

-   EntityPostResource ターゲットを作るために。
-   JobDescriptionResource 職務記述書の作成に使うために。

以下の例は、M.TargetとM.JobDescriptionを扱う際にエンティティAPIからジョブズAPIに切り替える方法を示しています。

### ジョブターゲットエンティティを作成する

こちらはEntities APIを使ってジョブターゲットエンティティを作成する例です。

POST /api/entities
Content-Type: application/json

{
 "properties": {
 "Target.StateDescription": <description>,
 "Target.Location": <location>
 },
 "relations": {
 "JobToTarget": {
 "parent": {
 "href": "https://<host>/api/entities/{jobId}"
 }
 }
 }
}

このものはJobs APIで次のように置き換えます:

POST /api/jobs/{jobId}/targets
Content-Type: application/json

{
 "properties": {
 "Target.StateDescription": <description>,
 "Target.Location": <location>
 }
}

### 職務記述書エンティティを作成する

こちらはEntities APIを使って職務記述書を作成する例です。

POST /api/entities
Content-Type: application/json

{
 "properties": {
 "Job.Data": {
 ...
 }
 },
 "relations": {
 "JobToTarget": {
 "parent": {
 "href": "https://<host>/api/entities/{jobId}"
 }
 }
 }
}

これをJobs APIを使ったものに置き換えてください。

PUT /api/jobs/{jobId}/description
Content-Type: application/json

{
 "properties": {
 "Job.Data": {
 ...
 }
 }
}

### 職務目標や職務内容を更新しましょう

Entities APIを使ってジョブターゲットや職務記述エンティティを更新するコールを特定したら、それらのコールをJobs APIに修正してください。

> !重要PUT操作はジョブに関連付けられたターゲットや記述に対して完全な更新を行います。リクエストに含まれていないプロパティや関係はnullに設定されます。
> 
> PATCH操作はジョブに関連付けられたターゲットや記述に対して部分的な更新を行います。リクエストに含まれるプロパティと関係のみが更新されます。

古いAPI呼び出しで使用されたリクエストボディが新しいAPIコールに正しくマッピングされていることを確認してください。新しいエンドポイントは以下のリクエストボディを期待します:

-   EntityResource ターゲットの更新(PUT)または部分的な更新(PATCH)のために使用されます。
-   JobDescriptionResource 更新用(PUT)と、職務記述書の部分更新用(PATCH)用EntityResourceです。

こちらはEntities APIを使ってジョブターゲットエンティティを更新するコールです:

PUT /api/entities/{id}
PUT /api/entities/identifier/{identifier}
Content-Type: application/json

{
 "properties": {
 "Target.StateDescription": <description>,
 "Target.Location": <location>
 },
 "relations": {
 "JobToTarget": {
 "parent": {
 "href": "https://<host>/api/entities/{jobId}"
 }
 }
 }
}

こちらはJobs APIを使ってジョブターゲットエンティティを更新するコールです:

PUT /api/jobs/{jobId}/targets/{targetId}
PATCH /api/jobs/{jobId}/targets/{targetId}
Content-Type: application/json

{
 "properties": {
 "Target.StateDescription": <description>,
 "Target.Location": <location>
 }
}

こちらはEntities APIを使って職務記述書エンティティを更新するコールです:

PUT /api/entities/{id}
PUT /api/entities/identifier/{identifier}
Content-Type: application/json

{
 "properties": {
 "Job.Data": {
 ...
 }
 },
 "relations": {
 "JobToTarget": {
 "parent": {
 "href": "https://<host>/api/entities/{jobId}"
 }
 }
 }
}

こちらはJobs APIを使って職務記述書エンティティを更新するコールです:

PUT /api/jobs/{jobId}/description
PATCH /api/jobs/{jobId}/description
Content-Type: application/json

{
 "properties": {
 "Job.Data": {
 ...
 }
 }
}

## 求人目標や職務記述書を削除するコールを見つけて更新する

Entities APIを使ってジョブターゲットや職務記述を削除するコールを特定したら、それらのコールをジョブAPIに更新してください。

こちらはEntities APIを使ってジョブターゲットエンティティを削除するコールです:

DELETE /api/entities/{ID}

このコールを次のように置き換えます:

DELETE /api/jobs/{jobId}/targets/{targetId}

こちらは職務記述書のエンティティを削除するものです:

DELETE /api/entities/{ID}

このコールを次のように置き換えます:

DELETE /api/jobs/{JOB\_ID}/description