更新域
命名空间:microsoft.graph
更新 domain 对象的属性。
重要提示: 只能更新已验证的域。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
Domain.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
Domain.ReadWrite.All |
HTTP 请求
PATCH /domains/{id}
对于 {id},请使用其完全限定的域名指定该域。
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json |
请求正文
在请求正文中,提供要更新的相关字段的值。 请求正文中未包含的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。 为获得最佳性能,仅包括更改的值。
响应
如果成功,此方法返回 响应 204 No Content 代码,无响应正文。
示例
请求
PATCH https://graph.microsoft.com/v1.0/domains/contoso.com
Content-type: application/json
{
"isDefault": true,
"supportedServices": [
"Email",
"OfficeCommunicationsOnline"
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var domain = new Domain
{
IsDefault = true,
SupportedServices = new List<String>()
{
"Email",
"OfficeCommunicationsOnline"
}
};
await graphClient.Domains["{domain-id}"]
.Request()
.UpdateAsync(domain);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const domain = {
isDefault: true,
supportedServices: [
'Email',
'OfficeCommunicationsOnline'
]
};
await client.api('/domains/contoso.com')
.update(domain);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/domains/contoso.com"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphDomain *domain = [[MSGraphDomain alloc] init];
[domain setIsDefault: true];
NSMutableArray *supportedServicesList = [[NSMutableArray alloc] init];
[supportedServicesList addObject: @"Email"];
[supportedServicesList addObject: @"OfficeCommunicationsOnline"];
[domain setSupportedServices:supportedServicesList];
NSError *error;
NSData *domainData = [domain getSerializedDataWithError:&error];
[urlRequest setHTTPBody:domainData];
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();
Domain domain = new Domain();
domain.isDefault = true;
LinkedList<String> supportedServicesList = new LinkedList<String>();
supportedServicesList.add("Email");
supportedServicesList.add("OfficeCommunicationsOnline");
domain.supportedServices = supportedServicesList;
graphClient.domains("contoso.com")
.buildRequest()
.patch(domain);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewDomain()
isDefault := true
requestBody.SetIsDefault(&isDefault)
requestBody.SetSupportedServices( []String {
"Email",
"OfficeCommunicationsOnline",
}
domainId := "domain-id"
graphClient.DomainsById(&domainId).Patch(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
IsDefault = $true
SupportedServices = @(
"Email"
"OfficeCommunicationsOnline"
)
}
Update-MgDomain -DomainId $domainId -BodyParameter $params
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
响应
HTTP/1.1 204 No Content