更新组织
命名空间:microsoft.graph
更新当前经过身份验证的组织的属性。 在这种情况下, organization 定义为一条记录的集合,因此必须在请求中指定其 ID 。 ID 也 称为组织的 tenantId。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
Organization.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
Organization.ReadWrite.All |
HTTP 请求
PATCH /organization/{id}
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json |
请求正文
在请求正文中,提供应更新的相关字段的值。 请求正文中不包括的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。 为了实现最佳性能,不得添加尚未变化的现有值。
| 属性 |
类型 |
说明 |
| marketingNotificationEmails |
String collection |
注意: 不可为 null。 |
| privacyProfile |
privacyProfile |
组织的隐私配置文件(设置 statementUrl 和 contactEmail)。 |
| securityComplianceNotificationMails |
String collection |
|
| securityComplianceNotificationPhones |
String collection |
|
| technicalNotificationMails |
String collection |
注意: 不可为 null。 |
响应
如果成功,此方法返回 204 No Content 响应代码。
示例
请求
PATCH https://graph.microsoft.com/v1.0/organization/84841066-274d-4ec0-a5c1-276be684bdd3
Content-type: application/json
{
"marketingNotificationEmails" : ["marketing@contoso.com"],
"privacyProfile" :
{
"contactEmail":"alice@contoso.com",
"statementUrl":"https://contoso.com/privacyStatement"
},
"securityComplianceNotificationMails" : ["security@contoso.com"],
"securityComplianceNotificationPhones" : ["(123) 456-7890"],
"technicalNotificationMails" : ["tech@contoso.com"]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var organization = new Organization
{
MarketingNotificationEmails = new List<String>()
{
"marketing@contoso.com"
},
PrivacyProfile = new PrivacyProfile
{
ContactEmail = "alice@contoso.com",
StatementUrl = "https://contoso.com/privacyStatement"
},
SecurityComplianceNotificationMails = new List<String>()
{
"security@contoso.com"
},
SecurityComplianceNotificationPhones = new List<String>()
{
"(123) 456-7890"
},
TechnicalNotificationMails = new List<String>()
{
"tech@contoso.com"
}
};
await graphClient.Organization["{organization-id}"]
.Request()
.UpdateAsync(organization);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const organization = {
marketingNotificationEmails: ['marketing@contoso.com'],
privacyProfile:
{
contactEmail: 'alice@contoso.com',
statementUrl: 'https://contoso.com/privacyStatement'
},
securityComplianceNotificationMails: ['security@contoso.com'],
securityComplianceNotificationPhones: ['(123) 456-7890'],
technicalNotificationMails: ['tech@contoso.com']
};
await client.api('/organization/84841066-274d-4ec0-a5c1-276be684bdd3')
.update(organization);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/organization/84841066-274d-4ec0-a5c1-276be684bdd3"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphOrganization *organization = [[MSGraphOrganization alloc] init];
NSMutableArray *marketingNotificationEmailsList = [[NSMutableArray alloc] init];
[marketingNotificationEmailsList addObject: @"marketing@contoso.com"];
[organization setMarketingNotificationEmails:marketingNotificationEmailsList];
MSGraphPrivacyProfile *privacyProfile = [[MSGraphPrivacyProfile alloc] init];
[privacyProfile setContactEmail:@"alice@contoso.com"];
[privacyProfile setStatementUrl:@"https://contoso.com/privacyStatement"];
[organization setPrivacyProfile:privacyProfile];
NSMutableArray *securityComplianceNotificationMailsList = [[NSMutableArray alloc] init];
[securityComplianceNotificationMailsList addObject: @"security@contoso.com"];
[organization setSecurityComplianceNotificationMails:securityComplianceNotificationMailsList];
NSMutableArray *securityComplianceNotificationPhonesList = [[NSMutableArray alloc] init];
[securityComplianceNotificationPhonesList addObject: @"(123) 456-7890"];
[organization setSecurityComplianceNotificationPhones:securityComplianceNotificationPhonesList];
NSMutableArray *technicalNotificationMailsList = [[NSMutableArray alloc] init];
[technicalNotificationMailsList addObject: @"tech@contoso.com"];
[organization setTechnicalNotificationMails:technicalNotificationMailsList];
NSError *error;
NSData *organizationData = [organization getSerializedDataWithError:&error];
[urlRequest setHTTPBody:organizationData];
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();
Organization organization = new Organization();
LinkedList<String> marketingNotificationEmailsList = new LinkedList<String>();
marketingNotificationEmailsList.add("marketing@contoso.com");
organization.marketingNotificationEmails = marketingNotificationEmailsList;
PrivacyProfile privacyProfile = new PrivacyProfile();
privacyProfile.contactEmail = "alice@contoso.com";
privacyProfile.statementUrl = "https://contoso.com/privacyStatement";
organization.privacyProfile = privacyProfile;
LinkedList<String> securityComplianceNotificationMailsList = new LinkedList<String>();
securityComplianceNotificationMailsList.add("security@contoso.com");
organization.securityComplianceNotificationMails = securityComplianceNotificationMailsList;
LinkedList<String> securityComplianceNotificationPhonesList = new LinkedList<String>();
securityComplianceNotificationPhonesList.add("(123) 456-7890");
organization.securityComplianceNotificationPhones = securityComplianceNotificationPhonesList;
LinkedList<String> technicalNotificationMailsList = new LinkedList<String>();
technicalNotificationMailsList.add("tech@contoso.com");
organization.technicalNotificationMails = technicalNotificationMailsList;
graphClient.organization("84841066-274d-4ec0-a5c1-276be684bdd3")
.buildRequest()
.patch(organization);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewOrganization()
requestBody.SetMarketingNotificationEmails( []String {
"marketing@contoso.com",
}
privacyProfile := msgraphsdk.NewPrivacyProfile()
requestBody.SetPrivacyProfile(privacyProfile)
contactEmail := "alice@contoso.com"
privacyProfile.SetContactEmail(&contactEmail)
statementUrl := "https://contoso.com/privacyStatement"
privacyProfile.SetStatementUrl(&statementUrl)
requestBody.SetSecurityComplianceNotificationMails( []String {
"security@contoso.com",
}
requestBody.SetSecurityComplianceNotificationPhones( []String {
"(123) 456-7890",
}
requestBody.SetTechnicalNotificationMails( []String {
"tech@contoso.com",
}
organizationId := "organization-id"
graphClient.OrganizationById(&organizationId).Patch(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
MarketingNotificationEmails = @(
"marketing@contoso.com"
)
PrivacyProfile = @{
ContactEmail = "alice@contoso.com"
StatementUrl = "https://contoso.com/privacyStatement"
}
SecurityComplianceNotificationMails = @(
"security@contoso.com"
)
SecurityComplianceNotificationPhones = @(
"(123) 456-7890"
)
TechnicalNotificationMails = @(
"tech@contoso.com"
)
}
Update-MgOrganization -OrganizationId $organizationId -BodyParameter $params
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
响应
HTTP/1.1 204 No Content