POST https://graph.microsoft.com/v1.0/education/users
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.educationUser",
"primaryRole": "String",
"middleName": "String",
"externalSource": "String",
"externalSourceDetail": "String",
"residenceAddress": {
"@odata.type": "microsoft.graph.physicalAddress"
},
"mailingAddress": {
"@odata.type": "microsoft.graph.physicalAddress"
},
"student": {
"@odata.type": "microsoft.graph.educationStudent"
},
"teacher": {
"@odata.type": "microsoft.graph.educationTeacher"
},
"createdBy": {
"@odata.type": "microsoft.graph.identitySet"
},
"accountEnabled": "Boolean",
"assignedLicenses": [
{
"@odata.type": "microsoft.graph.assignedLicense"
}
],
"assignedPlans": [
{
"@odata.type": "microsoft.graph.assignedPlan"
}
],
"businessPhones": [
"String"
],
"department": "String",
"displayName": "String",
"givenName": "String",
"mail": "String",
"mailNickname": "String",
"mobilePhone": "String",
"passwordPolicies": "String",
"passwordProfile": {
"@odata.type": "microsoft.graph.passwordProfile"
},
"officeLocation": "String",
"preferredLanguage": "String",
"provisionedPlans": [
{
"@odata.type": "microsoft.graph.provisionedPlan"
}
],
"refreshTokensValidFromDateTime": "String (timestamp)",
"showInAddressList": "Boolean",
"surname": "String",
"usageLocation": "String",
"userPrincipalName": "String",
"userType": "String",
"onPremisesInfo": {
"@odata.type": "microsoft.graph.educationOnPremisesInfo"
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var educationUser = new EducationUser
{
PrimaryRole = EducationUserRole.Student,
MiddleName = "String",
ExternalSource = EducationExternalSource.Sis,
ExternalSourceDetail = "String",
ResidenceAddress = new PhysicalAddress
{
},
MailingAddress = new PhysicalAddress
{
},
Student = new EducationStudent
{
},
Teacher = new EducationTeacher
{
},
CreatedBy = new IdentitySet
{
},
AccountEnabled = false,
AssignedLicenses = new List<AssignedLicense>()
{
new AssignedLicense
{
}
},
AssignedPlans = new List<AssignedPlan>()
{
new AssignedPlan
{
}
},
BusinessPhones = new List<String>()
{
"String"
},
Department = "String",
DisplayName = "String",
GivenName = "String",
Mail = "String",
MailNickname = "String",
MobilePhone = "String",
PasswordPolicies = "String",
PasswordProfile = new PasswordProfile
{
},
OfficeLocation = "String",
PreferredLanguage = "String",
ProvisionedPlans = new List<ProvisionedPlan>()
{
new ProvisionedPlan
{
}
},
RefreshTokensValidFromDateTime = DateTimeOffset.Parse("String (timestamp)"),
ShowInAddressList = false,
Surname = "String",
UsageLocation = "String",
UserPrincipalName = "String",
UserType = "String",
OnPremisesInfo = new EducationOnPremisesInfo
{
}
};
await graphClient.Education.Users
.Request()
.AddAsync(educationUser);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const educationUser = {
'@odata.type': '#microsoft.graph.educationUser',
primaryRole: 'String',
middleName: 'String',
externalSource: 'String',
externalSourceDetail: 'String',
residenceAddress: {
'@odata.type': 'microsoft.graph.physicalAddress'
},
mailingAddress: {
'@odata.type': 'microsoft.graph.physicalAddress'
},
student: {
'@odata.type': 'microsoft.graph.educationStudent'
},
teacher: {
'@odata.type': 'microsoft.graph.educationTeacher'
},
createdBy: {
'@odata.type': 'microsoft.graph.identitySet'
},
accountEnabled: 'Boolean',
assignedLicenses: [
{
'@odata.type': 'microsoft.graph.assignedLicense'
}
],
assignedPlans: [
{
'@odata.type': 'microsoft.graph.assignedPlan'
}
],
businessPhones: [
'String'
],
department: 'String',
displayName: 'String',
givenName: 'String',
mail: 'String',
mailNickname: 'String',
mobilePhone: 'String',
passwordPolicies: 'String',
passwordProfile: {
'@odata.type': 'microsoft.graph.passwordProfile'
},
officeLocation: 'String',
preferredLanguage: 'String',
provisionedPlans: [
{
'@odata.type': 'microsoft.graph.provisionedPlan'
}
],
refreshTokensValidFromDateTime: 'String (timestamp)',
showInAddressList: 'Boolean',
surname: 'String',
usageLocation: 'String',
userPrincipalName: 'String',
userType: 'String',
onPremisesInfo: {
'@odata.type': 'microsoft.graph.educationOnPremisesInfo'
}
};
await client.api('/education/users')
.post(educationUser);
有关如何将 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/users"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphEducationUser *educationUser = [[MSGraphEducationUser alloc] init];
[educationUser setPrimaryRole: [MSGraphEducationUserRole student]];
[educationUser setMiddleName:@"String"];
[educationUser setExternalSource: [MSGraphEducationExternalSource sis]];
[educationUser setExternalSourceDetail:@"String"];
MSGraphPhysicalAddress *residenceAddress = [[MSGraphPhysicalAddress alloc] init];
[educationUser setResidenceAddress:residenceAddress];
MSGraphPhysicalAddress *mailingAddress = [[MSGraphPhysicalAddress alloc] init];
[educationUser setMailingAddress:mailingAddress];
MSGraphEducationStudent *student = [[MSGraphEducationStudent alloc] init];
[educationUser setStudent:student];
MSGraphEducationTeacher *teacher = [[MSGraphEducationTeacher alloc] init];
[educationUser setTeacher:teacher];
MSGraphIdentitySet *createdBy = [[MSGraphIdentitySet alloc] init];
[educationUser setCreatedBy:createdBy];
[educationUser setAccountEnabled:@"Boolean"];
NSMutableArray *assignedLicensesList = [[NSMutableArray alloc] init];
MSGraphAssignedLicense *assignedLicenses = [[MSGraphAssignedLicense alloc] init];
[assignedLicensesList addObject: assignedLicenses];
[educationUser setAssignedLicenses:assignedLicensesList];
NSMutableArray *assignedPlansList = [[NSMutableArray alloc] init];
MSGraphAssignedPlan *assignedPlans = [[MSGraphAssignedPlan alloc] init];
[assignedPlansList addObject: assignedPlans];
[educationUser setAssignedPlans:assignedPlansList];
NSMutableArray *businessPhonesList = [[NSMutableArray alloc] init];
[businessPhonesList addObject: @"String"];
[educationUser setBusinessPhones:businessPhonesList];
[educationUser setDepartment:@"String"];
[educationUser setDisplayName:@"String"];
[educationUser setGivenName:@"String"];
[educationUser setMail:@"String"];
[educationUser setMailNickname:@"String"];
[educationUser setMobilePhone:@"String"];
[educationUser setPasswordPolicies:@"String"];
MSGraphPasswordProfile *passwordProfile = [[MSGraphPasswordProfile alloc] init];
[educationUser setPasswordProfile:passwordProfile];
[educationUser setOfficeLocation:@"String"];
[educationUser setPreferredLanguage:@"String"];
NSMutableArray *provisionedPlansList = [[NSMutableArray alloc] init];
MSGraphProvisionedPlan *provisionedPlans = [[MSGraphProvisionedPlan alloc] init];
[provisionedPlansList addObject: provisionedPlans];
[educationUser setProvisionedPlans:provisionedPlansList];
[educationUser setRefreshTokensValidFromDateTime:@"String (timestamp)"];
[educationUser setShowInAddressList:@"Boolean"];
[educationUser setSurname:@"String"];
[educationUser setUsageLocation:@"String"];
[educationUser setUserPrincipalName:@"String"];
[educationUser setUserType:@"String"];
MSGraphEducationOnPremisesInfo *onPremisesInfo = [[MSGraphEducationOnPremisesInfo alloc] init];
[educationUser setOnPremisesInfo:onPremisesInfo];
NSError *error;
NSData *educationUserData = [educationUser getSerializedDataWithError:&error];
[urlRequest setHTTPBody:educationUserData];
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();
EducationUser educationUser = new EducationUser();
educationUser.primaryRole = EducationUserRole.STUDENT;
educationUser.middleName = "String";
educationUser.externalSource = EducationExternalSource.SIS;
educationUser.externalSourceDetail = "String";
PhysicalAddress residenceAddress = new PhysicalAddress();
educationUser.residenceAddress = residenceAddress;
PhysicalAddress mailingAddress = new PhysicalAddress();
educationUser.mailingAddress = mailingAddress;
EducationStudent student = new EducationStudent();
educationUser.student = student;
EducationTeacher teacher = new EducationTeacher();
educationUser.teacher = teacher;
IdentitySet createdBy = new IdentitySet();
educationUser.createdBy = createdBy;
educationUser.accountEnabled = false;
LinkedList<AssignedLicense> assignedLicensesList = new LinkedList<AssignedLicense>();
AssignedLicense assignedLicenses = new AssignedLicense();
assignedLicensesList.add(assignedLicenses);
educationUser.assignedLicenses = assignedLicensesList;
LinkedList<AssignedPlan> assignedPlansList = new LinkedList<AssignedPlan>();
AssignedPlan assignedPlans = new AssignedPlan();
assignedPlansList.add(assignedPlans);
educationUser.assignedPlans = assignedPlansList;
LinkedList<String> businessPhonesList = new LinkedList<String>();
businessPhonesList.add("String");
educationUser.businessPhones = businessPhonesList;
educationUser.department = "String";
educationUser.displayName = "String";
educationUser.givenName = "String";
educationUser.mail = "String";
educationUser.mailNickname = "String";
educationUser.mobilePhone = "String";
educationUser.passwordPolicies = "String";
PasswordProfile passwordProfile = new PasswordProfile();
educationUser.passwordProfile = passwordProfile;
educationUser.officeLocation = "String";
educationUser.preferredLanguage = "String";
LinkedList<ProvisionedPlan> provisionedPlansList = new LinkedList<ProvisionedPlan>();
ProvisionedPlan provisionedPlans = new ProvisionedPlan();
provisionedPlansList.add(provisionedPlans);
educationUser.provisionedPlans = provisionedPlansList;
educationUser.refreshTokensValidFromDateTime = OffsetDateTimeSerializer.deserialize("String (timestamp)");
educationUser.showInAddressList = false;
educationUser.surname = "String";
educationUser.usageLocation = "String";
educationUser.userPrincipalName = "String";
educationUser.userType = "String";
EducationOnPremisesInfo onPremisesInfo = new EducationOnPremisesInfo();
educationUser.onPremisesInfo = onPremisesInfo;
graphClient.education().users()
.buildRequest()
.post(educationUser);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewEducationUser()
primaryRole := "String"
requestBody.SetPrimaryRole(&primaryRole)
middleName := "String"
requestBody.SetMiddleName(&middleName)
externalSource := "String"
requestBody.SetExternalSource(&externalSource)
externalSourceDetail := "String"
requestBody.SetExternalSourceDetail(&externalSourceDetail)
residenceAddress := msgraphsdk.NewPhysicalAddress()
requestBody.SetResidenceAddress(residenceAddress)
residenceAddress.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.physicalAddress",
}
mailingAddress := msgraphsdk.NewPhysicalAddress()
requestBody.SetMailingAddress(mailingAddress)
mailingAddress.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.physicalAddress",
}
student := msgraphsdk.NewEducationStudent()
requestBody.SetStudent(student)
student.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.educationStudent",
}
teacher := msgraphsdk.NewEducationTeacher()
requestBody.SetTeacher(teacher)
teacher.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.educationTeacher",
}
createdBy := msgraphsdk.NewIdentitySet()
requestBody.SetCreatedBy(createdBy)
createdBy.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.identitySet",
}
accountEnabled := "Boolean"
requestBody.SetAccountEnabled(&accountEnabled)
requestBody.SetAssignedLicenses( []AssignedLicense {
msgraphsdk.NewAssignedLicense(),
SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.assignedLicense",
}
}
requestBody.SetAssignedPlans( []AssignedPlan {
msgraphsdk.NewAssignedPlan(),
SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.assignedPlan",
}
}
requestBody.SetBusinessPhones( []String {
"String",
}
department := "String"
requestBody.SetDepartment(&department)
displayName := "String"
requestBody.SetDisplayName(&displayName)
givenName := "String"
requestBody.SetGivenName(&givenName)
mail := "String"
requestBody.SetMail(&mail)
mailNickname := "String"
requestBody.SetMailNickname(&mailNickname)
mobilePhone := "String"
requestBody.SetMobilePhone(&mobilePhone)
passwordPolicies := "String"
requestBody.SetPasswordPolicies(&passwordPolicies)
passwordProfile := msgraphsdk.NewPasswordProfile()
requestBody.SetPasswordProfile(passwordProfile)
passwordProfile.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.passwordProfile",
}
officeLocation := "String"
requestBody.SetOfficeLocation(&officeLocation)
preferredLanguage := "String"
requestBody.SetPreferredLanguage(&preferredLanguage)
requestBody.SetProvisionedPlans( []ProvisionedPlan {
msgraphsdk.NewProvisionedPlan(),
SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.provisionedPlan",
}
}
refreshTokensValidFromDateTime, err := time.Parse(time.RFC3339, "String (timestamp)")
requestBody.SetRefreshTokensValidFromDateTime(&refreshTokensValidFromDateTime)
showInAddressList := "Boolean"
requestBody.SetShowInAddressList(&showInAddressList)
surname := "String"
requestBody.SetSurname(&surname)
usageLocation := "String"
requestBody.SetUsageLocation(&usageLocation)
userPrincipalName := "String"
requestBody.SetUserPrincipalName(&userPrincipalName)
userType := "String"
requestBody.SetUserType(&userType)
onPremisesInfo := msgraphsdk.NewEducationOnPremisesInfo()
requestBody.SetOnPremisesInfo(onPremisesInfo)
onPremisesInfo.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.educationOnPremisesInfo",
}
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.educationUser",
}
result, err := graphClient.Education().Users().Post(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Education
$params = @{
"@odata.type" = "#microsoft.graph.educationUser"
PrimaryRole = "String"
MiddleName = "String"
ExternalSource = "String"
ExternalSourceDetail = "String"
ResidenceAddress = @{
"@odata.type" = "microsoft.graph.physicalAddress"
}
MailingAddress = @{
"@odata.type" = "microsoft.graph.physicalAddress"
}
Student = @{
"@odata.type" = "microsoft.graph.educationStudent"
}
Teacher = @{
"@odata.type" = "microsoft.graph.educationTeacher"
}
CreatedBy = @{
"@odata.type" = "microsoft.graph.identitySet"
}
AccountEnabled = "Boolean"
AssignedLicenses = @(
@{
"@odata.type" = "microsoft.graph.assignedLicense"
}
)
AssignedPlans = @(
@{
"@odata.type" = "microsoft.graph.assignedPlan"
}
)
BusinessPhones = @(
"String"
)
Department = "String"
DisplayName = "String"
GivenName = "String"
Mail = "String"
MailNickname = "String"
MobilePhone = "String"
PasswordPolicies = "String"
PasswordProfile = @{
"@odata.type" = "microsoft.graph.passwordProfile"
}
OfficeLocation = "String"
PreferredLanguage = "String"
ProvisionedPlans = @(
@{
"@odata.type" = "microsoft.graph.provisionedPlan"
}
)
RefreshTokensValidFromDateTime = [System.DateTime]::Parse("String (timestamp)")
ShowInAddressList = "Boolean"
Surname = "String"
UsageLocation = "String"
UserPrincipalName = "String"
UserType = "String"
OnPremisesInfo = @{
"@odata.type" = "microsoft.graph.educationOnPremisesInfo"
}
}
New-MgEducationUser -BodyParameter $params
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。