获取 educationUser
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
检索用户的属性和关系。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
备注
如果使用委派令牌,成员只能看到有关其自己的帐户的信息。 在这种情况下,使用 beta/education/me/users 资源。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
EduRoster.ReadBasic
委派(个人 Microsoft 帐户)
不支持。
应用程序
EduRoster.Read.All、EduRoster.ReadWrite.All
重要
使用委派权限范围时,Graph将仅返回一组有限的属性:、 id primaryRole accountEnabled displayName givenName surname userPrincipalName userType onPremisesInfo student/externalId teacher/externalId 。 如果应用程序需要其他属性,则必须使用应用程序权限范围。
HTTP 请求
GET /education/me
GET /education/users/{id}
可选的查询参数
此方法支持 OData 查询参数 来帮助自定义响应。
标头
值
Authorization
Bearer {token}。必需。
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法会在响应正文中返回 200 OK 响应代码和 educationUser 对象。
示例
请求
下面展示了示例请求。
GET https://graph.microsoft.com/beta/education/users/13012
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var educationUser = await graphClient.Education.Users["{educationUser-id}"]
.Request()
.GetAsync();
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var user = await graphClient.Education.Me.User
.Request()
.GetAsync();
const options = {
authProvider,
};
const client = Client.init(options);
let educationUser = await client.api('/education/users/13012')
.version('beta')
.get();
const options = {
authProvider,
};
const client = Client.init(options);
let user = await client.api('/education/me/user')
.version('beta')
.get();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/education/users/13012"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphEducationUser *educationUser = [[MSGraphEducationUser alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/education/me/user"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphUser *user = [[MSGraphUser alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
EducationUser educationUser = graphClient.education().users("13012")
.buildRequest()
.get();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
educationUserId := "educationUser-id"
result, err := graphClient.Education().UsersById(&educationUserId).Get()
Import-Module Microsoft.Graph.Education
Get-MgEducationUser -EducationUserId $educationUserId
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"id": "13012",
"displayName": "Dion Matheson",
"givenName": "Dion",
"middleName": " ",
"surname": "Matheson",
"mail": "DionM@contoso.com",
"mobilePhone": "+1 (253) 555-0101",
"createdBy": {
"user": {
"displayName": "Susana Rocha",
"id": "14012"
}
},
"externalSource": "sis",
"mailingAddress": {
"city": "Los Angeles",
"countryOrRegion": "United States",
"postalCode": "98055",
"state": "CA",
"street": "12345 Main St."
},
"primaryRole": "student",
"residenceAddress": {
"city": "Los Angeles",
"countryOrRegion": "United States",
"postalCode": "98055",
"state": "CA",
"street": "12345 Main St."
},
}