创建 educationClass
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
创建新课程。 此操作还会创建通用组。 使用此 API 创建课程时,它会向组添加特殊属性,这将在使用组创建团队时在 Microsoft Teams 中添加分配和特殊处理等功能。 请注意,此 API 仅创建通用组,不会创建团队。 Microsoft Teams为教师提供了用户界面,以使用此 API 创建的组创建自己的班级团队。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
不支持。
委派(个人 Microsoft 帐户)
不支持。
应用程序
EduRoster.ReadWrite.All
HTTP 请求
POST /education/classes
标头
值
Authorization
Bearer {token}。必需。
Content-Type
application/json
请求正文
在请求正文中,提供 educationClass 对象的 JSON 表示形式。
响应
如果成功,此方法会在响应正文中返回 201 Created 响应代码和 educationClass 对象。
示例
请求
下面展示了示例请求。
POST https://graph.microsoft.com/beta/education/classes
Content-type: application/json
{
"description": "Health Level 1",
"classCode": "Health 501",
"displayName": "Health 1",
"externalId": "11019",
"externalName": "Health Level 1",
"externalSource": "sis",
"mailNickname": "fineartschool.net"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var educationClass = new EducationClass
{
Description = "Health Level 1",
ClassCode = "Health 501",
DisplayName = "Health 1",
ExternalId = "11019",
ExternalName = "Health Level 1",
ExternalSource = EducationExternalSource.Sis,
MailNickname = "fineartschool.net"
};
await graphClient.Education.Classes
.Request()
.AddAsync(educationClass);
const options = {
authProvider,
};
const client = Client.init(options);
const educationClass = {
description: 'Health Level 1',
classCode: 'Health 501',
displayName: 'Health 1',
externalId: '11019',
externalName: 'Health Level 1',
externalSource: 'sis',
mailNickname: 'fineartschool.net'
};
await client.api('/education/classes')
.version('beta')
.post(educationClass);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/education/classes"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphEducationClass *educationClass = [[MSGraphEducationClass alloc] init];
[educationClass setDescription:@"Health Level 1"];
[educationClass setClassCode:@"Health 501"];
[educationClass setDisplayName:@"Health 1"];
[educationClass setExternalId:@"11019"];
[educationClass setExternalName:@"Health Level 1"];
[educationClass setExternalSource: [MSGraphEducationExternalSource sis]];
[educationClass setMailNickname:@"fineartschool.net"];
NSError *error;
NSData *educationClassData = [educationClass getSerializedDataWithError:&error];
[urlRequest setHTTPBody:educationClassData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
EducationClass educationClass = new EducationClass();
educationClass.description = "Health Level 1";
educationClass.classCode = "Health 501";
educationClass.displayName = "Health 1";
educationClass.externalId = "11019";
educationClass.externalName = "Health Level 1";
educationClass.externalSource = EducationExternalSource.SIS;
educationClass.mailNickname = "fineartschool.net";
graphClient.education().classes()
.buildRequest()
.post(educationClass);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewEducationClass()
description := "Health Level 1"
requestBody.SetDescription(&description)
classCode := "Health 501"
requestBody.SetClassCode(&classCode)
displayName := "Health 1"
requestBody.SetDisplayName(&displayName)
externalId := "11019"
requestBody.SetExternalId(&externalId)
externalName := "Health Level 1"
requestBody.SetExternalName(&externalName)
externalSource := "sis"
requestBody.SetExternalSource(&externalSource)
mailNickname := "fineartschool.net"
requestBody.SetMailNickname(&mailNickname)
result, err := graphClient.Education().Classes().Post(requestBody)
Import-Module Microsoft.Graph.Education
$params = @{
Description = "Health Level 1"
ClassCode = "Health 501"
DisplayName = "Health 1"
ExternalId = "11019"
ExternalName = "Health Level 1"
ExternalSource = "sis"
MailNickname = "fineartschool.net"
}
New-MgEducationClass -BodyParameter $params
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "11019",
"description": "Health Level 1",
"classCode": "Health 501",
"createdBy": {
"user": {
"displayName": "Susana Rocha",
"id": "14012",
}
},
"displayName": "Health 1",
"externalId": "11019",
"externalName": "Health Level 1",
"externalSource": "sis",
"mailNickname": "fineartschool.net"
}