创建语言
命名空间:microsoft.graph
此方法用于在 B2C 用户流中Azure AD自定义语言。
注意: 必须先在 B2C 用户Azure AD中启用语言自定义,然后才能创建自定义语言。 有关详细信息,请参阅更新 b2cIdentityUserFlow。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
IdentityUserFlow.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
IdentityUserFlow.ReadWrite.All |
工作或学校帐户需要属于以下角色之一:
HTTP 请求
PUT /identity/b2cUserFlows/{id}/languages/{id}
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,提供 userFlowLanguageConfiguration 对象的 JSON 表示形式。
下表显示创建 userFlowLanguageConfiguration时可以选择提供的属性。
| 属性 |
类型 |
说明 |
| id |
String |
语言的标识符。 此字段与语言 ID 标记 RFC 5646 兼容,并且必须是记录的语言 ID。 如果在请求正文中提供,则它必须匹配请求 URL 中提供标识。 |
| isEnabled |
Boolean |
指示语言是否在用户流中启用。 如果请求中未提供,isEnabled 将设置为"true"。 |
响应
如果成功,此方法在响应正文中返回 响应代码和 201 Created userFlowLanguageConfiguration 对象。
示例
示例 1:在 B2C 用户流Azure AD自定义语言
请求
下面展示了示例请求。
PUT https://graph.microsoft.com/beta/identity/b2cUserFlows/B2C_1_CustomerSignUp/languages/es-ES
Content-Type: application/json
{
"id": "es-ES",
"isEnabled": true
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var userFlowLanguageConfiguration = new UserFlowLanguageConfiguration
{
Id = "es-ES",
IsEnabled = true
};
await graphClient.Identity.B2cUserFlows["{b2cIdentityUserFlow-id}"].Languages["{userFlowLanguageConfiguration-id}"]
.Request()
.PutAsync(userFlowLanguageConfiguration);
const options = {
authProvider,
};
const client = Client.init(options);
const userFlowLanguageConfiguration = {
id: 'es-ES',
isEnabled: true
};
await client.api('/identity/b2cUserFlows/B2C_1_CustomerSignUp/languages/es-ES')
.version('beta')
.put(userFlowLanguageConfiguration);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/identity/b2cUserFlows/B2C_1_CustomerSignUp/languages/es-ES"]]];
[urlRequest setHTTPMethod:@"PUT"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphUserFlowLanguageConfiguration *userFlowLanguageConfiguration = [[MSGraphUserFlowLanguageConfiguration alloc] init];
[userFlowLanguageConfiguration setId:@"es-ES"];
[userFlowLanguageConfiguration setIsEnabled: true];
NSError *error;
NSData *userFlowLanguageConfigurationData = [userFlowLanguageConfiguration getSerializedDataWithError:&error];
[urlRequest setHTTPBody:userFlowLanguageConfigurationData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
UserFlowLanguageConfiguration userFlowLanguageConfiguration = new UserFlowLanguageConfiguration();
userFlowLanguageConfiguration.id = "es-ES";
userFlowLanguageConfiguration.isEnabled = true;
graphClient.identity().b2cUserFlows("B2C_1_CustomerSignUp").languages("es-ES")
.buildRequest()
.put(userFlowLanguageConfiguration);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
requestBody.SetAdditionalData(map[string]interface{}{
"id": "es-ES",
"isEnabled": true,
}
b2cIdentityUserFlowId := "b2cIdentityUserFlow-id"
userFlowLanguageConfigurationId := "userFlowLanguageConfiguration-id"
graphClient.Identity().B2cUserFlowsById(&b2cIdentityUserFlowId).LanguagesById(&userFlowLanguageConfigurationId).Put(requestBody)
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#identity/b2cUserFlows('B2C_1_CustomerSignUp')/languages/$entity",
"id": "es-ES",
"isEnabled": true,
"displayName": "Spanish (Spain)"
}
示例 2:更新 B2C 用户Azure AD中的自定义语言
请求
下面展示了示例请求。
PUT https://graph.microsoft.com/beta/identity/b2cUserFlows/B2C_1_CustomerSignUp/languages/es-ES
Content-Type: application/json
{
"isEnabled": false
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var userFlowLanguageConfiguration = new UserFlowLanguageConfiguration
{
IsEnabled = false
};
await graphClient.Identity.B2cUserFlows["{b2cIdentityUserFlow-id}"].Languages["{userFlowLanguageConfiguration-id}"]
.Request()
.PutAsync(userFlowLanguageConfiguration);
const options = {
authProvider,
};
const client = Client.init(options);
const userFlowLanguageConfiguration = {
isEnabled: false
};
await client.api('/identity/b2cUserFlows/B2C_1_CustomerSignUp/languages/es-ES')
.version('beta')
.put(userFlowLanguageConfiguration);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/identity/b2cUserFlows/B2C_1_CustomerSignUp/languages/es-ES"]]];
[urlRequest setHTTPMethod:@"PUT"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphUserFlowLanguageConfiguration *userFlowLanguageConfiguration = [[MSGraphUserFlowLanguageConfiguration alloc] init];
[userFlowLanguageConfiguration setIsEnabled: false];
NSError *error;
NSData *userFlowLanguageConfigurationData = [userFlowLanguageConfiguration getSerializedDataWithError:&error];
[urlRequest setHTTPBody:userFlowLanguageConfigurationData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
UserFlowLanguageConfiguration userFlowLanguageConfiguration = new UserFlowLanguageConfiguration();
userFlowLanguageConfiguration.isEnabled = false;
graphClient.identity().b2cUserFlows("B2C_1_CustomerSignUp").languages("es-ES")
.buildRequest()
.put(userFlowLanguageConfiguration);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
requestBody.SetAdditionalData(map[string]interface{}{
"isEnabled": false,
}
b2cIdentityUserFlowId := "b2cIdentityUserFlow-id"
userFlowLanguageConfigurationId := "userFlowLanguageConfiguration-id"
graphClient.Identity().B2cUserFlowsById(&b2cIdentityUserFlowId).LanguagesById(&userFlowLanguageConfigurationId).Put(requestBody)
响应
下面展示了示例响应。
HTTP/1.1 204 No Content