创建 educationSchool
命名空间:microsoft.graph
创建新的 educationSchool 对象。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
不支持。 |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
EduRoster.ReadWrite.All |
HTTP 请求
POST /education/schools
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,提供 educationSchool 对象的 JSON 表示形式。
下表显示创建 educationSchool 时所需的属性。
| 属性 |
类型 |
说明 |
| displayName |
String |
学校的显示名称。 继承自 educationOrganization。 |
| 说明 |
String |
学校描述。 继承自 educationOrganization。 |
| externalSource |
educationExternalSource |
创建组织的来源。 继承自 educationOrganization。 可能的值是 sis :、'manual。 |
| externalSourceDetail |
String |
生成此资源的外部源的名称。 |
| principalEmail |
String |
主体的电子邮件地址。 |
| principalName |
String |
主体名称。 |
| externalPrincipalId |
String |
同步系统中主体的 ID。 |
| highestGrade |
String |
教授的最高年级。 |
| lowestGrade |
String |
教授的最低年级。 |
| schoolNumber |
String |
学校编号。 |
| externalId |
String |
同步系统中学校的 ID。 |
| phone |
String |
学校电话号码。 |
| fax |
String |
学校传真号码。 |
| createdBy |
identitySet |
创建了学校的实体。 |
| address |
physicalAddress |
学校地址。 |
响应
如果成功,此方法会在响应正文中返回 201 Created 响应代码和 educationSchool 对象。
示例
请求
POST https://graph.microsoft.com/v1.0/education/schools
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.educationSchool",
"displayName": "String",
"description": "String",
"externalSource": "String",
"externalSourceDetail": "String",
"principalEmail": "String",
"principalName": "String",
"externalPrincipalId": "String",
"lowestGrade": "String",
"highestGrade": "String",
"schoolNumber": "String",
"externalId": "String",
"phone": "String",
"fax": "String",
"createdBy": {
"@odata.type": "microsoft.graph.identitySet"
},
"address": {
"@odata.type": "microsoft.graph.physicalAddress"
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var educationSchool = new EducationSchool
{
DisplayName = "String",
Description = "String",
ExternalSource = EducationExternalSource.Sis,
ExternalSourceDetail = "String",
PrincipalEmail = "String",
PrincipalName = "String",
ExternalPrincipalId = "String",
LowestGrade = "String",
HighestGrade = "String",
SchoolNumber = "String",
ExternalId = "String",
Phone = "String",
Fax = "String",
CreatedBy = new IdentitySet
{
},
Address = new PhysicalAddress
{
}
};
await graphClient.Education.Schools
.Request()
.AddAsync(educationSchool);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const educationSchool = {
'@odata.type': '#microsoft.graph.educationSchool',
displayName: 'String',
description: 'String',
externalSource: 'String',
externalSourceDetail: 'String',
principalEmail: 'String',
principalName: 'String',
externalPrincipalId: 'String',
lowestGrade: 'String',
highestGrade: 'String',
schoolNumber: 'String',
externalId: 'String',
phone: 'String',
fax: 'String',
createdBy: {
'@odata.type': 'microsoft.graph.identitySet'
},
address: {
'@odata.type': 'microsoft.graph.physicalAddress'
}
};
await client.api('/education/schools')
.post(educationSchool);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/education/schools"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphEducationSchool *educationSchool = [[MSGraphEducationSchool alloc] init];
[educationSchool setDisplayName:@"String"];
[educationSchool setDescription:@"String"];
[educationSchool setExternalSource: [MSGraphEducationExternalSource sis]];
[educationSchool setExternalSourceDetail:@"String"];
[educationSchool setPrincipalEmail:@"String"];
[educationSchool setPrincipalName:@"String"];
[educationSchool setExternalPrincipalId:@"String"];
[educationSchool setLowestGrade:@"String"];
[educationSchool setHighestGrade:@"String"];
[educationSchool setSchoolNumber:@"String"];
[educationSchool setExternalId:@"String"];
[educationSchool setPhone:@"String"];
[educationSchool setFax:@"String"];
MSGraphIdentitySet *createdBy = [[MSGraphIdentitySet alloc] init];
[educationSchool setCreatedBy:createdBy];
MSGraphPhysicalAddress *address = [[MSGraphPhysicalAddress alloc] init];
[educationSchool setAddress:address];
NSError *error;
NSData *educationSchoolData = [educationSchool getSerializedDataWithError:&error];
[urlRequest setHTTPBody:educationSchoolData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
EducationSchool educationSchool = new EducationSchool();
educationSchool.displayName = "String";
educationSchool.description = "String";
educationSchool.externalSource = EducationExternalSource.SIS;
educationSchool.externalSourceDetail = "String";
educationSchool.principalEmail = "String";
educationSchool.principalName = "String";
educationSchool.externalPrincipalId = "String";
educationSchool.lowestGrade = "String";
educationSchool.highestGrade = "String";
educationSchool.schoolNumber = "String";
educationSchool.externalId = "String";
educationSchool.phone = "String";
educationSchool.fax = "String";
IdentitySet createdBy = new IdentitySet();
educationSchool.createdBy = createdBy;
PhysicalAddress address = new PhysicalAddress();
educationSchool.address = address;
graphClient.education().schools()
.buildRequest()
.post(educationSchool);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewEducationSchool()
displayName := "String"
requestBody.SetDisplayName(&displayName)
description := "String"
requestBody.SetDescription(&description)
externalSource := "String"
requestBody.SetExternalSource(&externalSource)
externalSourceDetail := "String"
requestBody.SetExternalSourceDetail(&externalSourceDetail)
principalEmail := "String"
requestBody.SetPrincipalEmail(&principalEmail)
principalName := "String"
requestBody.SetPrincipalName(&principalName)
externalPrincipalId := "String"
requestBody.SetExternalPrincipalId(&externalPrincipalId)
lowestGrade := "String"
requestBody.SetLowestGrade(&lowestGrade)
highestGrade := "String"
requestBody.SetHighestGrade(&highestGrade)
schoolNumber := "String"
requestBody.SetSchoolNumber(&schoolNumber)
externalId := "String"
requestBody.SetExternalId(&externalId)
phone := "String"
requestBody.SetPhone(&phone)
fax := "String"
requestBody.SetFax(&fax)
createdBy := msgraphsdk.NewIdentitySet()
requestBody.SetCreatedBy(createdBy)
createdBy.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.identitySet",
}
address := msgraphsdk.NewPhysicalAddress()
requestBody.SetAddress(address)
address.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.physicalAddress",
}
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.educationSchool",
}
result, err := graphClient.Education().Schools().Post(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Education
$params = @{
"@odata.type" = "#microsoft.graph.educationSchool"
DisplayName = "String"
Description = "String"
ExternalSource = "String"
ExternalSourceDetail = "String"
PrincipalEmail = "String"
PrincipalName = "String"
ExternalPrincipalId = "String"
LowestGrade = "String"
HighestGrade = "String"
SchoolNumber = "String"
ExternalId = "String"
Phone = "String"
Fax = "String"
CreatedBy = @{
"@odata.type" = "microsoft.graph.identitySet"
}
Address = @{
"@odata.type" = "microsoft.graph.physicalAddress"
}
}
New-MgEducationSchool -BodyParameter $params
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
响应
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.educationSchool",
"id": "1c23c12e-c12e-1c23-2ec1-231c2ec1231c",
"displayName": "String",
"description": "String",
"externalSource": "String",
"externalSourceDetail": "String",
"principalEmail": "String",
"principalName": "String",
"externalPrincipalId": "String",
"lowestGrade": "String",
"highestGrade": "String",
"schoolNumber": "String",
"externalId": "String",
"phone": "String",
"fax": "String",
"createdBy": {
"@odata.type": "microsoft.graph.identitySet"
},
"address": {
"@odata.type": "microsoft.graph.physicalAddress"
}
}