名前空間: microsoft.graph
サポートするリソースの種類を拡張するために、新しい schemaExtension 定義とそれに関連付けられているスキーマ拡張プロパティを作成します。
スキーマ拡張機能を使用すると、厳密に型指定されたカスタム データをリソースに追加できます。 スキーマ拡張機能を作成するアプリは所有者アプリです。 拡張機能の 状態 によっては、所有者アプリと所有者アプリのみが拡張機能を更新または削除する場合があります。
トレーニング コースを説明するスキーマ拡張機能を定義する方法、スキーマ拡張定義を使用してトレーニング コース データで新規グループを作成する方法、既存グループにトレーニング コース データを追加する方法については、それぞれの例を参照してください。
この API は、次の国内クラウド展開で使用できます。
| グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
| ✅ |
✅ |
✅ |
✅ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
| アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
| 委任 (職場または学校のアカウント) |
Application.ReadWrite.All |
注意事項なし。 |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
| アプリケーション |
Application.ReadWrite.All and Directory.ReadWrite.All |
注意事項なし。 |
注:
また、委任されたフローの場合は、サインインしているユーザーが、呼び出し元アプリケーションの所有者であるか、所有者 プロパティの設定に使用する appId を持つアプリケーションの所有者である必要があります。
HTTP 要求
POST /schemaExtensions
| 名前 |
説明 |
| Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
| Content-Type |
application/json |
要求本文
要求本文では、schemaExtension オブジェクトの JSON 表記を指定します。
次の表に、スキーマ拡張機能の作成時に必要なプロパティを示します。
| パラメーター |
型 |
説明 |
| description |
String |
省略可能。 スキーマ拡張機能の説明。 |
| id |
String |
必須です。 スキーマ拡張機能の定義の一意の識別子。 値の割り当ては、以下の 2 方法のいずれかで行うことができます。- 検証済みドメインの 1 つの名前とスキーマ拡張機能の名前を連結して、この形式の一意の文字列 {domainName}_{schemaName} を形成します。 次に例
contoso_mySchema を示します。 注: 上位ドメイン .com、.net、.gov、.edu、.org の下では、検証済みのドメインのみがサポートされます。 - スキーマ名を指定し、Microsoft Graph でそのスキーマ名を使用して、ext{8-random-英数字-chars}_{schema-name} という形式で ID の割り当てを完了させます。 たとえば、
extkvbmkofy_mySchema。 作成後、このプロパティは変更できません。 |
| owner |
String |
条件付きの。 スキーマ拡張機能の所有者であるアプリケーションの appId です。 既定では、呼び出し元アプリケーションの appId が owner として設定されます。 ただし、このプロパティは、owner appId を呼び出し元アプリとは異なるものに設定するように作成時に指定することができます。 いずれの場合も、委任されたフローでは、サインインしたユーザーが、スキーマ拡張機能の所有者として設定されるアプリケーションの所有者である必要があります。 たとえば、Graph エクスプローラーを使用して新しいスキーマ拡張機能の定義を作成する場合は、owner プロパティを、所有している appId に指定する必要があります。 設定すると、このプロパティは読み取り専用で、変更することはできません。 |
| properties |
extensionSchemaProperty コレクション |
必須です。 スキーマ拡張機能の定義を構成するプロパティの名前と種類のコレクション。 |
| targetTypes |
String collection |
必須です。 このスキーマ拡張機能の定義を適用できる、(スキーマ拡張機能をサポートしている) 一連の Microsoft Graph のリソースの種類。 |
応答
成功した場合、このメソッドは応答本文で 201 Created 応答コードと、schemaExtension オブジェクトを返します。
例
例 1: 確認済みのドメインを使用してスキーマ拡張機能を作成する
要求
この例では、確認済みのドメイン名 graphlearn とスキーマ名 courses を使用して、スキーマ拡張機能の定義の id プロパティの一意の文字列を形成します。 一意の文字列は、{domainName}_{schemaName} という形式に基づいています。 要求本文から 所有者 を除外すると、Microsoft Graph は、呼び出し元がこの要求を行うアプリの所有者であると想定します。
POST https://graph.microsoft.com/v1.0/schemaExtensions
Content-type: application/json
{
"id":"graphlearn_courses",
"description": "Graph Learn training courses extensions",
"targetTypes": [
"Group"
],
"properties": [
{
"name": "courseId",
"type": "Integer"
},
{
"name": "courseName",
"type": "String"
},
{
"name": "courseType",
"type": "String"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new SchemaExtension
{
Id = "graphlearn_courses",
Description = "Graph Learn training courses extensions",
TargetTypes = new List<string>
{
"Group",
},
Properties = new List<ExtensionSchemaProperty>
{
new ExtensionSchemaProperty
{
Name = "courseId",
Type = "Integer",
},
new ExtensionSchemaProperty
{
Name = "courseName",
Type = "String",
},
new ExtensionSchemaProperty
{
Name = "courseType",
Type = "String",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.SchemaExtensions.PostAsync(requestBody);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSchemaExtension()
id := "graphlearn_courses"
requestBody.SetId(&id)
description := "Graph Learn training courses extensions"
requestBody.SetDescription(&description)
targetTypes := []string {
"Group",
}
requestBody.SetTargetTypes(targetTypes)
extensionSchemaProperty := graphmodels.NewExtensionSchemaProperty()
name := "courseId"
extensionSchemaProperty.SetName(&name)
type := "Integer"
extensionSchemaProperty.SetType(&type)
extensionSchemaProperty1 := graphmodels.NewExtensionSchemaProperty()
name := "courseName"
extensionSchemaProperty1.SetName(&name)
type := "String"
extensionSchemaProperty1.SetType(&type)
extensionSchemaProperty2 := graphmodels.NewExtensionSchemaProperty()
name := "courseType"
extensionSchemaProperty2.SetName(&name)
type := "String"
extensionSchemaProperty2.SetType(&type)
properties := []graphmodels.ExtensionSchemaPropertyable {
extensionSchemaProperty,
extensionSchemaProperty1,
extensionSchemaProperty2,
}
requestBody.SetProperties(properties)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
schemaExtensions, err := graphClient.SchemaExtensions().Post(context.Background(), requestBody, nil)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SchemaExtension schemaExtension = new SchemaExtension();
schemaExtension.setId("graphlearn_courses");
schemaExtension.setDescription("Graph Learn training courses extensions");
LinkedList<String> targetTypes = new LinkedList<String>();
targetTypes.add("Group");
schemaExtension.setTargetTypes(targetTypes);
LinkedList<ExtensionSchemaProperty> properties = new LinkedList<ExtensionSchemaProperty>();
ExtensionSchemaProperty extensionSchemaProperty = new ExtensionSchemaProperty();
extensionSchemaProperty.setName("courseId");
extensionSchemaProperty.setType("Integer");
properties.add(extensionSchemaProperty);
ExtensionSchemaProperty extensionSchemaProperty1 = new ExtensionSchemaProperty();
extensionSchemaProperty1.setName("courseName");
extensionSchemaProperty1.setType("String");
properties.add(extensionSchemaProperty1);
ExtensionSchemaProperty extensionSchemaProperty2 = new ExtensionSchemaProperty();
extensionSchemaProperty2.setName("courseType");
extensionSchemaProperty2.setType("String");
properties.add(extensionSchemaProperty2);
schemaExtension.setProperties(properties);
SchemaExtension result = graphClient.schemaExtensions().post(schemaExtension);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
const options = {
authProvider,
};
const client = Client.init(options);
const schemaExtension = {
id: 'graphlearn_courses',
description: 'Graph Learn training courses extensions',
targetTypes: [
'Group'
],
properties: [
{
name: 'courseId',
type: 'Integer'
},
{
name: 'courseName',
type: 'String'
},
{
name: 'courseType',
type: 'String'
}
]
};
await client.api('/schemaExtensions')
.post(schemaExtension);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\SchemaExtension;
use Microsoft\Graph\Generated\Models\ExtensionSchemaProperty;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SchemaExtension();
$requestBody->setId('graphlearn_courses');
$requestBody->setDescription('Graph Learn training courses extensions');
$requestBody->setTargetTypes(['Group', ]);
$propertiesExtensionSchemaProperty1 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty1->setName('courseId');
$propertiesExtensionSchemaProperty1->setType('Integer');
$propertiesArray []= $propertiesExtensionSchemaProperty1;
$propertiesExtensionSchemaProperty2 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty2->setName('courseName');
$propertiesExtensionSchemaProperty2->setType('String');
$propertiesArray []= $propertiesExtensionSchemaProperty2;
$propertiesExtensionSchemaProperty3 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty3->setName('courseType');
$propertiesExtensionSchemaProperty3->setType('String');
$propertiesArray []= $propertiesExtensionSchemaProperty3;
$requestBody->setProperties($propertiesArray);
$result = $graphServiceClient->schemaExtensions()->post($requestBody)->wait();
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.SchemaExtensions
$params = @{
id = "graphlearn_courses"
description = "Graph Learn training courses extensions"
targetTypes = @(
"Group"
)
properties = @(
@{
name = "courseId"
type = "Integer"
}
@{
name = "courseName"
type = "String"
}
@{
name = "courseType"
type = "String"
}
)
}
New-MgSchemaExtension -BodyParameter $params
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.schema_extension import SchemaExtension
from msgraph.generated.models.extension_schema_property import ExtensionSchemaProperty
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SchemaExtension(
id = "graphlearn_courses",
description = "Graph Learn training courses extensions",
target_types = [
"Group",
],
properties = [
ExtensionSchemaProperty(
name = "courseId",
type = "Integer",
),
ExtensionSchemaProperty(
name = "courseName",
type = "String",
),
ExtensionSchemaProperty(
name = "courseType",
type = "String",
),
],
)
result = await graph_client.schema_extensions.post(request_body)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "graphlearn_courses",
"description": "Graph Learn training courses extensions",
"targetTypes": [
"Group"
],
"status": "InDevelopment",
"owner": "24d3b144-21ae-4080-943f-7067b395b913",
"properties": [
{
"name": "courseId",
"type": "String"
},
{
"name": "courseName",
"type": "String"
},
{
"name": "courseType",
"type": "String"
}
]
}
例 2: 名前のみを使用してスキーマ拡張機能を作成する
要求
次の例では、要求の id プロパティにスキーマ名coursesだけを指定し、schemaExtension オブジェクトの残りのプロパティの JSON 表現を指定する例を示します。 Microsoft Graph は一意の文字列値を割り当て、それを応答内で返します。 要求本文から 所有者 を除外すると、Microsoft Graph は、呼び出し元がこの要求を行うアプリの所有者であると想定します。
POST https://graph.microsoft.com/v1.0/schemaExtensions
Content-type: application/json
{
"id":"courses",
"description": "Graph Learn training courses extensions",
"targetTypes": [
"Group"
],
"properties": [
{
"name": "courseId",
"type": "Integer"
},
{
"name": "courseName",
"type": "String"
},
{
"name": "courseType",
"type": "String"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new SchemaExtension
{
Id = "courses",
Description = "Graph Learn training courses extensions",
TargetTypes = new List<string>
{
"Group",
},
Properties = new List<ExtensionSchemaProperty>
{
new ExtensionSchemaProperty
{
Name = "courseId",
Type = "Integer",
},
new ExtensionSchemaProperty
{
Name = "courseName",
Type = "String",
},
new ExtensionSchemaProperty
{
Name = "courseType",
Type = "String",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.SchemaExtensions.PostAsync(requestBody);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSchemaExtension()
id := "courses"
requestBody.SetId(&id)
description := "Graph Learn training courses extensions"
requestBody.SetDescription(&description)
targetTypes := []string {
"Group",
}
requestBody.SetTargetTypes(targetTypes)
extensionSchemaProperty := graphmodels.NewExtensionSchemaProperty()
name := "courseId"
extensionSchemaProperty.SetName(&name)
type := "Integer"
extensionSchemaProperty.SetType(&type)
extensionSchemaProperty1 := graphmodels.NewExtensionSchemaProperty()
name := "courseName"
extensionSchemaProperty1.SetName(&name)
type := "String"
extensionSchemaProperty1.SetType(&type)
extensionSchemaProperty2 := graphmodels.NewExtensionSchemaProperty()
name := "courseType"
extensionSchemaProperty2.SetName(&name)
type := "String"
extensionSchemaProperty2.SetType(&type)
properties := []graphmodels.ExtensionSchemaPropertyable {
extensionSchemaProperty,
extensionSchemaProperty1,
extensionSchemaProperty2,
}
requestBody.SetProperties(properties)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
schemaExtensions, err := graphClient.SchemaExtensions().Post(context.Background(), requestBody, nil)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SchemaExtension schemaExtension = new SchemaExtension();
schemaExtension.setId("courses");
schemaExtension.setDescription("Graph Learn training courses extensions");
LinkedList<String> targetTypes = new LinkedList<String>();
targetTypes.add("Group");
schemaExtension.setTargetTypes(targetTypes);
LinkedList<ExtensionSchemaProperty> properties = new LinkedList<ExtensionSchemaProperty>();
ExtensionSchemaProperty extensionSchemaProperty = new ExtensionSchemaProperty();
extensionSchemaProperty.setName("courseId");
extensionSchemaProperty.setType("Integer");
properties.add(extensionSchemaProperty);
ExtensionSchemaProperty extensionSchemaProperty1 = new ExtensionSchemaProperty();
extensionSchemaProperty1.setName("courseName");
extensionSchemaProperty1.setType("String");
properties.add(extensionSchemaProperty1);
ExtensionSchemaProperty extensionSchemaProperty2 = new ExtensionSchemaProperty();
extensionSchemaProperty2.setName("courseType");
extensionSchemaProperty2.setType("String");
properties.add(extensionSchemaProperty2);
schemaExtension.setProperties(properties);
SchemaExtension result = graphClient.schemaExtensions().post(schemaExtension);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
const options = {
authProvider,
};
const client = Client.init(options);
const schemaExtension = {
id: 'courses',
description: 'Graph Learn training courses extensions',
targetTypes: [
'Group'
],
properties: [
{
name: 'courseId',
type: 'Integer'
},
{
name: 'courseName',
type: 'String'
},
{
name: 'courseType',
type: 'String'
}
]
};
await client.api('/schemaExtensions')
.post(schemaExtension);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\SchemaExtension;
use Microsoft\Graph\Generated\Models\ExtensionSchemaProperty;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SchemaExtension();
$requestBody->setId('courses');
$requestBody->setDescription('Graph Learn training courses extensions');
$requestBody->setTargetTypes(['Group', ]);
$propertiesExtensionSchemaProperty1 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty1->setName('courseId');
$propertiesExtensionSchemaProperty1->setType('Integer');
$propertiesArray []= $propertiesExtensionSchemaProperty1;
$propertiesExtensionSchemaProperty2 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty2->setName('courseName');
$propertiesExtensionSchemaProperty2->setType('String');
$propertiesArray []= $propertiesExtensionSchemaProperty2;
$propertiesExtensionSchemaProperty3 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty3->setName('courseType');
$propertiesExtensionSchemaProperty3->setType('String');
$propertiesArray []= $propertiesExtensionSchemaProperty3;
$requestBody->setProperties($propertiesArray);
$result = $graphServiceClient->schemaExtensions()->post($requestBody)->wait();
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.SchemaExtensions
$params = @{
id = "courses"
description = "Graph Learn training courses extensions"
targetTypes = @(
"Group"
)
properties = @(
@{
name = "courseId"
type = "Integer"
}
@{
name = "courseName"
type = "String"
}
@{
name = "courseType"
type = "String"
}
)
}
New-MgSchemaExtension -BodyParameter $params
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.schema_extension import SchemaExtension
from msgraph.generated.models.extension_schema_property import ExtensionSchemaProperty
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SchemaExtension(
id = "courses",
description = "Graph Learn training courses extensions",
target_types = [
"Group",
],
properties = [
ExtensionSchemaProperty(
name = "courseId",
type = "Integer",
),
ExtensionSchemaProperty(
name = "courseName",
type = "String",
),
ExtensionSchemaProperty(
name = "courseType",
type = "String",
),
],
)
result = await graph_client.schema_extensions.post(request_body)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
応答には、要求の中で提供されているスキーマ名に基づいた一意の文字列がその id プロパティ内に含まれ、新規作成したスキーマ定義の残りの部分も応答に含まれています。
応答の id の値は、ext{8-random-英数字-chars}_{schema-name} という形式に基づいています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "extk9eruy7c_courses",
"description": "Graph Learn training courses extensions",
"targetTypes": [
"Group"
],
"status": "InDevelopment",
"owner": "24d3b144-21ae-4080-943f-7067b395b913",
"properties": [
{
"name": "courseId",
"type": "String"
},
{
"name": "courseName",
"type": "String"
},
{
"name": "courseType",
"type": "String"
}
]
}
例 3: 所有者を設定してスキーマ拡張機能を作成する
要求
次の例では、owner を設定してスキーマ拡張機能を作成する方法を示します。 このシナリオでは、アプリケーションのユーザーがアプリケーションの所有者でない可能性があります (たとえば、Microsoft Graph Explorer を使用している場合)。 この場合は、 owner プロパティを、所有しているアプリケーションの appId に設定する必要があります。設定しなかった場合は、スキーマ拡張の作成を承認されません。 要求の owner プロパティを設定し、schemaExtension オブジェクト内の残りのプロパティの JSON 表記を使用します。
POST https://graph.microsoft.com/v1.0/schemaExtensions
Content-type: application/json
{
"id":"courses",
"description": "Graph Learn training courses extensions",
"targetTypes": [
"Group"
],
"owner": "50897f70-a455-4adf-87bc-4cf17091d5ac",
"properties": [
{
"name": "courseId",
"type": "Integer"
},
{
"name": "courseName",
"type": "String"
},
{
"name": "courseType",
"type": "String"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new SchemaExtension
{
Id = "courses",
Description = "Graph Learn training courses extensions",
TargetTypes = new List<string>
{
"Group",
},
Owner = "50897f70-a455-4adf-87bc-4cf17091d5ac",
Properties = new List<ExtensionSchemaProperty>
{
new ExtensionSchemaProperty
{
Name = "courseId",
Type = "Integer",
},
new ExtensionSchemaProperty
{
Name = "courseName",
Type = "String",
},
new ExtensionSchemaProperty
{
Name = "courseType",
Type = "String",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.SchemaExtensions.PostAsync(requestBody);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSchemaExtension()
id := "courses"
requestBody.SetId(&id)
description := "Graph Learn training courses extensions"
requestBody.SetDescription(&description)
targetTypes := []string {
"Group",
}
requestBody.SetTargetTypes(targetTypes)
owner := "50897f70-a455-4adf-87bc-4cf17091d5ac"
requestBody.SetOwner(&owner)
extensionSchemaProperty := graphmodels.NewExtensionSchemaProperty()
name := "courseId"
extensionSchemaProperty.SetName(&name)
type := "Integer"
extensionSchemaProperty.SetType(&type)
extensionSchemaProperty1 := graphmodels.NewExtensionSchemaProperty()
name := "courseName"
extensionSchemaProperty1.SetName(&name)
type := "String"
extensionSchemaProperty1.SetType(&type)
extensionSchemaProperty2 := graphmodels.NewExtensionSchemaProperty()
name := "courseType"
extensionSchemaProperty2.SetName(&name)
type := "String"
extensionSchemaProperty2.SetType(&type)
properties := []graphmodels.ExtensionSchemaPropertyable {
extensionSchemaProperty,
extensionSchemaProperty1,
extensionSchemaProperty2,
}
requestBody.SetProperties(properties)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
schemaExtensions, err := graphClient.SchemaExtensions().Post(context.Background(), requestBody, nil)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SchemaExtension schemaExtension = new SchemaExtension();
schemaExtension.setId("courses");
schemaExtension.setDescription("Graph Learn training courses extensions");
LinkedList<String> targetTypes = new LinkedList<String>();
targetTypes.add("Group");
schemaExtension.setTargetTypes(targetTypes);
schemaExtension.setOwner("50897f70-a455-4adf-87bc-4cf17091d5ac");
LinkedList<ExtensionSchemaProperty> properties = new LinkedList<ExtensionSchemaProperty>();
ExtensionSchemaProperty extensionSchemaProperty = new ExtensionSchemaProperty();
extensionSchemaProperty.setName("courseId");
extensionSchemaProperty.setType("Integer");
properties.add(extensionSchemaProperty);
ExtensionSchemaProperty extensionSchemaProperty1 = new ExtensionSchemaProperty();
extensionSchemaProperty1.setName("courseName");
extensionSchemaProperty1.setType("String");
properties.add(extensionSchemaProperty1);
ExtensionSchemaProperty extensionSchemaProperty2 = new ExtensionSchemaProperty();
extensionSchemaProperty2.setName("courseType");
extensionSchemaProperty2.setType("String");
properties.add(extensionSchemaProperty2);
schemaExtension.setProperties(properties);
SchemaExtension result = graphClient.schemaExtensions().post(schemaExtension);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
const options = {
authProvider,
};
const client = Client.init(options);
const schemaExtension = {
id: 'courses',
description: 'Graph Learn training courses extensions',
targetTypes: [
'Group'
],
owner: '50897f70-a455-4adf-87bc-4cf17091d5ac',
properties: [
{
name: 'courseId',
type: 'Integer'
},
{
name: 'courseName',
type: 'String'
},
{
name: 'courseType',
type: 'String'
}
]
};
await client.api('/schemaExtensions')
.post(schemaExtension);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\SchemaExtension;
use Microsoft\Graph\Generated\Models\ExtensionSchemaProperty;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SchemaExtension();
$requestBody->setId('courses');
$requestBody->setDescription('Graph Learn training courses extensions');
$requestBody->setTargetTypes(['Group', ]);
$requestBody->setOwner('50897f70-a455-4adf-87bc-4cf17091d5ac');
$propertiesExtensionSchemaProperty1 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty1->setName('courseId');
$propertiesExtensionSchemaProperty1->setType('Integer');
$propertiesArray []= $propertiesExtensionSchemaProperty1;
$propertiesExtensionSchemaProperty2 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty2->setName('courseName');
$propertiesExtensionSchemaProperty2->setType('String');
$propertiesArray []= $propertiesExtensionSchemaProperty2;
$propertiesExtensionSchemaProperty3 = new ExtensionSchemaProperty();
$propertiesExtensionSchemaProperty3->setName('courseType');
$propertiesExtensionSchemaProperty3->setType('String');
$propertiesArray []= $propertiesExtensionSchemaProperty3;
$requestBody->setProperties($propertiesArray);
$result = $graphServiceClient->schemaExtensions()->post($requestBody)->wait();
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.SchemaExtensions
$params = @{
id = "courses"
description = "Graph Learn training courses extensions"
targetTypes = @(
"Group"
)
owner = "50897f70-a455-4adf-87bc-4cf17091d5ac"
properties = @(
@{
name = "courseId"
type = "Integer"
}
@{
name = "courseName"
type = "String"
}
@{
name = "courseType"
type = "String"
}
)
}
New-MgSchemaExtension -BodyParameter $params
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.schema_extension import SchemaExtension
from msgraph.generated.models.extension_schema_property import ExtensionSchemaProperty
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SchemaExtension(
id = "courses",
description = "Graph Learn training courses extensions",
target_types = [
"Group",
],
owner = "50897f70-a455-4adf-87bc-4cf17091d5ac",
properties = [
ExtensionSchemaProperty(
name = "courseId",
type = "Integer",
),
ExtensionSchemaProperty(
name = "courseName",
type = "String",
),
ExtensionSchemaProperty(
name = "courseType",
type = "String",
),
],
)
result = await graph_client.schema_extensions.post(request_body)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
応答には、要求で指定された値に設定された owner が含まれます。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "extk9eruy7c_courses",
"description": "Graph Learn training courses extensions",
"targetTypes": [
"Group"
],
"status": "InDevelopment",
"owner": "50897f70-a455-4adf-87bc-4cf17091d5ac",
"properties": [
{
"name": "courseId",
"type": "String"
},
{
"name": "courseName",
"type": "String"
},
{
"name": "courseType",
"type": "String"
}
]
}
関連コンテンツ