outlookUser: supportedTimeZones
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
获取用户支持的时区列表,就像在用户的邮箱服务器上配置的那样。
可以显式指定以 Windows 时区格式返回时区,或者以 Internet 号码分配局 (IANA) 时区 (也称为“Olson 时区”)格式返回。 Windows 时区是默认格式。
在设置 Outlook 客户端时,用户从此受支持的列表中选择首选时区。 随后可以通过获取用户的邮箱设置 获取首选时区。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
User.Read、User.ReadBasic.All
委派(个人 Microsoft 帐户)
User.Read
Application
User.Read.All
HTTP 请求
GET /me/outlook/supportedTimeZones
GET /users/{id|userPrincipalName}/outlook/supportedTimeZones
GET /me/outlook/supportedTimeZones(TimeZoneStandard=microsoft.graph.timeZoneStandard'{timezone_format}')
GET /users/{id|userPrincipalName}/outlook/supportedTimeZones(TimeZoneStandard=microsoft.graph.timeZoneStandard'{timezone_format}')
函数参数
参数
类型
说明
TimeZoneStandard
String
时区格式。 支持的值:Windows 和 Iana。 可选。
名称
类型
说明
Authorization
string
Bearer {token}。必需。
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法在响应正文中返回 200 OK 响应代码和 timeZoneInformation 对象的集合。
示例
请求 1
以下示例未指定 timeZoneStandard 参数,并获取以 Windows 时区格式表示的受支持的时区列表。
GET https://graph.microsoft.com/beta/me/outlook/supportedTimeZones
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var supportedTimeZones = await graphClient.Me.Outlook
.SupportedTimeZones()
.Request()
.GetAsync();
const options = {
authProvider,
};
const client = Client.init(options);
let supportedTimeZones = await client.api('/me/outlook/supportedTimeZones')
.version('beta')
.get();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/outlook/supportedTimeZones"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphTimeZoneInformation *timeZoneInformation = [[MSGraphTimeZoneInformation alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
OutlookUserSupportedTimeZonesCollectionPage supportedTimeZones = graphClient.me().outlook()
.supportedTimeZones()
.buildRequest()
.get();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.Me().Outlook().SupportedTimeZones()().Get()
Import-Module Microsoft.Graph.Users.Functions
# A UPN can also be used as -UserId.
Invoke-MgTimeUserOutlook -UserId $userId
响应 1
下面是一个响应示例。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.timeZoneInformation)",
"value":[
{
"alias":"Dateline Standard Time",
"displayName":"(UTC-12:00) International Date Line West"
},
{
"alias":"Samoa Standard Time",
"displayName":"(UTC+13:00) Samoa"
},
{
"alias":"UTC-11",
"displayName":"(UTC-11:00) Coordinated Universal Time-11"
},
{
"alias":"Aleutian Standard Time",
"displayName":"(UTC-10:00) Aleutian Islands"
}
]
}
请求 2
以下示例指定 TimeZoneStandard 参数的 Iana,并获取以 IANA 格式表示的受支持的时区列表。
GET https://graph.microsoft.com/beta/me/outlook/supportedTimeZones(TimeZoneStandard=microsoft.graph.timeZoneStandard'Iana')
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var supportedTimeZones = await graphClient.Me.Outlook
.SupportedTimeZones(TimeZoneStandard.Iana)
.Request()
.GetAsync();
const options = {
authProvider,
};
const client = Client.init(options);
let supportedTimeZones = await client.api('/me/outlook/supportedTimeZones(TimeZoneStandard=microsoft.graph.timeZoneStandard'Iana')')
.version('beta')
.get();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/outlook/supportedTimeZones(TimeZoneStandard=microsoft.graph.timeZoneStandard'Iana')"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphTimeZoneInformation *timeZoneInformation = [[MSGraphTimeZoneInformation alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
OutlookUserSupportedTimeZonesCollectionPage supportedTimeZones = graphClient.me().outlook()
.supportedTimeZones(OutlookUserSupportedTimeZonesParameterSet
.newBuilder()
.withTimeZoneStandard(microsoft.graph.timeZoneStandard'Iana')
.build())
.buildRequest()
.get();
响应 2
下面是一个响应示例。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.timeZoneInformation)",
"value":[
{
"alias":"Etc/GMT+12",
"displayName":"Etc/GMT+12"
},
{
"alias":"US/Samoa",
"displayName":"US/Samoa"
},
{
"alias":"Etc/GMT+11",
"displayName":"Etc/GMT+11"
},
{
"alias":"US/Aleutian",
"displayName":"US/Aleutian"
}
]
}