创建 identityUserFlowAttribute
命名空间:microsoft.graph
创建新的 identityUserFlowAttribute 对象。
Permissions
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
IdentityUserFlow.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
IdentityUserFlow.ReadWrite.All |
工作或学校帐户需要属于以下角色之一:
HTTP 请求
POST /identity/userFlowAttributes
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,提供 identityUserFlowAttribute的 JSON 表示形式。
| 属性 |
类型 |
说明 |
| id |
String |
用户流属性的标识符。 这是一个自动创建的只读属性。 |
| displayName |
String |
用户流属性的显示名称。 |
| 说明 |
String |
用户流属性的说明。 注册时,它向用户显示。 |
| userFlowAttributeType |
String |
用户流属性的类型。 这是一个自动设置的只读属性。 此属性的值将是 builtIn 或 custom,具体取决于属性的类型。 |
| DataType |
String |
用户流属性的数据类型。 一旦创建自定义用户流属性,就无法对其进行修改。 dataType 支持的值有:
|
响应
如果成功,此方法在响应 201 Created 正文中返回 响应代码和 identityUserFlowAttribute 对象。 如果失败,将返回 4xx 错误并显示具体详细信息。
示例
请求
下面展示了示例请求。
POST https://graph.microsoft.com/v1.0/identity/userFlowAttributes
Content-type: application/json
{
"displayName": "Hobby",
"description": "Your hobby",
"dataType": "string",
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var identityUserFlowAttribute = new IdentityUserFlowAttribute
{
DisplayName = "Hobby",
Description = "Your hobby",
DataType = IdentityUserFlowAttributeDataType.String
};
await graphClient.Identity.UserFlowAttributes
.Request()
.AddAsync(identityUserFlowAttribute);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const identityUserFlowAttribute = {
displayName: 'Hobby',
description: 'Your hobby',
dataType: 'string',
};
await client.api('/identity/userFlowAttributes')
.post(identityUserFlowAttribute);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/identity/userFlowAttributes"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphIdentityUserFlowAttribute *identityUserFlowAttribute = [[MSGraphIdentityUserFlowAttribute alloc] init];
[identityUserFlowAttribute setDisplayName:@"Hobby"];
[identityUserFlowAttribute setDescription:@"Your hobby"];
[identityUserFlowAttribute setDataType: [MSGraphIdentityUserFlowAttributeDataType string]];
NSError *error;
NSData *identityUserFlowAttributeData = [identityUserFlowAttribute getSerializedDataWithError:&error];
[urlRequest setHTTPBody:identityUserFlowAttributeData];
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();
IdentityUserFlowAttribute identityUserFlowAttribute = new IdentityUserFlowAttribute();
identityUserFlowAttribute.displayName = "Hobby";
identityUserFlowAttribute.description = "Your hobby";
identityUserFlowAttribute.dataType = IdentityUserFlowAttributeDataType.STRING;
graphClient.identity().userFlowAttributes()
.buildRequest()
.post(identityUserFlowAttribute);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewIdentityUserFlowAttribute()
displayName := "Hobby"
requestBody.SetDisplayName(&displayName)
description := "Your hobby"
requestBody.SetDescription(&description)
dataType := "string"
requestBody.SetDataType(&dataType)
result, err := graphClient.Identity().UserFlowAttributes().Post(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Location: https://graph.microsoft.com/v1.0/identity/userFlowAttributes/extension_7a95ecd9489b4fb9a45722b913c4703b_Hobby
Content-type: application/json
{
"id": "extension_d09380e2b4c642b9a203fb816a04a7ad_Hobby",
"displayName": "Hobby",
"description": "Your hobby",
"userFlowAttributeType": "custom",
"dataType": "string"
}