Create userAttributeAssignments
Article
06/08/2023
5 contributors
Feedback
In this article
Namespace: microsoft.graph
Create a new identityUserFlowAttributeAssignment object in a b2xIdentityUserFlow .
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
IdentityUserFlow.ReadWrite.All
Delegated (personal Microsoft account)
Not supported
Application
IdentityUserFlow.ReadWrite.All
HTTP request
POST /identity/b2xUserFlows/{id}/userAttributeAssignments
Name
Description
Authorization
Bearer {token}. Required.
Content-Type
application/json. Required.
Request body
In the request body, supply a JSON representation of the identityUserFlowAttributeAssignment object.
The following table shows the properties that are required when you create the identityUserFlowAttributeAssignment .
Property
Type
Description
displayName
String
The display name of the identityUserFlowAttribute within a user flow.
isOptional
Boolean
Determines whether the identityUserFlowAttribute is optional. true
means the user doesn't have to provide a value. false
means the user cannot complete sign-up without providing a value.
requiresVerification
Boolean
Determines whether the identityUserFlowAttribute requires verification. This is only used for verifying the user's phone number or email address.
userAttributeValues
userAttributeValuesItem collection
The input options for the user flow attribute. Only applicable when the userInputType is radioSingleSelect
, dropdownSingleSelect
, or checkboxMultiSelect
.
userInputType
identityUserFlowAttributeInputType
The input type of the user flow attribute. Possible values are: textBox
, dateTimeDropdown
, radioSingleSelect
, dropdownSingleSelect
, emailBox
, checkboxMultiSelect
.
userAttribute
identityUserFlowAttribute
The identifier for the user flow attribute to include in the user flow assignment.
Response
If successful, this method returns a 201 Created
response code and an identityUserFlowAttributeAssignment object in the response body.
Examples
Request
POST https://graph.microsoft.com/v1.0/identity/b2xUserFlows/B2X_1_Partner/userAttributeAssignments
Content-Type: application/json
{
"isOptional": false,
"requiresVerification": false,
"userInputType": "TextBox",
"displayName": "Shoe size",
"userAttributeValues": [],
"userAttribute": {
"id": "extension_guid_shoeSize"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new IdentityUserFlowAttributeAssignment
{
IsOptional = false,
RequiresVerification = false,
UserInputType = IdentityUserFlowAttributeInputType.TextBox,
DisplayName = "Shoe size",
UserAttributeValues = new List<UserAttributeValuesItem>
{
},
UserAttribute = new IdentityUserFlowAttribute
{
Id = "extension_guid_shoeSize",
},
};
var result = await graphClient.Identity.B2xUserFlows["{b2xIdentityUserFlow-id}"].UserAttributeAssignments.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc identity b2x-user-flows user-attribute-assignments create --b2x-identity-user-flow-id {b2xIdentityUserFlow-id} --body '{\
"isOptional": false,\
"requiresVerification": false,\
"userInputType": "TextBox",\
"displayName": "Shoe size",\
"userAttributeValues": [],\
"userAttribute": {\
"id": "extension_guid_shoeSize"\
}\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewIdentityUserFlowAttributeAssignment()
isOptional := false
requestBody.SetIsOptional(&isOptional)
requiresVerification := false
requestBody.SetRequiresVerification(&requiresVerification)
userInputType := graphmodels.TEXTBOX_IDENTITYUSERFLOWATTRIBUTEINPUTTYPE
requestBody.SetUserInputType(&userInputType)
displayName := "Shoe size"
requestBody.SetDisplayName(&displayName)
userAttributeValues := []graphmodels.UserAttributeValuesItemable {
}
requestBody.SetUserAttributeValues(userAttributeValues)
userAttribute := graphmodels.NewIdentityUserFlowAttribute()
id := "extension_guid_shoeSize"
userAttribute.SetId(&id)
requestBody.SetUserAttribute(userAttribute)
userAttributeAssignments, err := graphClient.Identity().B2xUserFlows().ByB2xIdentityUserFlowId("b2xIdentityUserFlow-id").UserAttributeAssignments().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
IdentityUserFlowAttributeAssignment identityUserFlowAttributeAssignment = new IdentityUserFlowAttributeAssignment();
identityUserFlowAttributeAssignment.isOptional = false;
identityUserFlowAttributeAssignment.requiresVerification = false;
identityUserFlowAttributeAssignment.userInputType = IdentityUserFlowAttributeInputType.TEXT_BOX;
identityUserFlowAttributeAssignment.displayName = "Shoe size";
LinkedList<UserAttributeValuesItem> userAttributeValuesList = new LinkedList<UserAttributeValuesItem>();
identityUserFlowAttributeAssignment.userAttributeValues = userAttributeValuesList;
IdentityUserFlowAttribute userAttribute = new IdentityUserFlowAttribute();
userAttribute.id = "extension_guid_shoeSize";
identityUserFlowAttributeAssignment.userAttribute = userAttribute;
graphClient.identity().b2xUserFlows("B2X_1_Partner").userAttributeAssignments()
.buildRequest()
.post(identityUserFlowAttributeAssignment);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
const identityUserFlowAttributeAssignment = {
isOptional: false,
requiresVerification: false,
userInputType: 'TextBox',
displayName: 'Shoe size',
userAttributeValues: [],
userAttribute: {
id: 'extension_guid_shoeSize'
}
};
await client.api('/identity/b2xUserFlows/B2X_1_Partner/userAttributeAssignments')
.post(identityUserFlowAttributeAssignment);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new IdentityUserFlowAttributeAssignment();
$requestBody->setIsOptional(false);
$requestBody->setRequiresVerification(false);
$requestBody->setUserInputType(new IdentityUserFlowAttributeInputType('textBox'));
$requestBody->setDisplayName('Shoe size');
$requestBody->setUserAttributeValues([ ]);
$userAttribute = new IdentityUserFlowAttribute();
$userAttribute->setId('extension_guid_shoeSize');
$requestBody->setUserAttribute($userAttribute);
$result = $graphServiceClient->identity()->b2xUserFlows()->byB2xIdentityUserFlowId('b2xIdentityUserFlow-id')->userAttributeAssignments()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
isOptional = $false
requiresVerification = $false
userInputType = "TextBox"
displayName = "Shoe size"
userAttributeValues = @(
)
userAttribute = @{
id = "extension_guid_shoeSize"
}
}
New-MgIdentityB2XUserFlowUserAttributeAssignment -B2xIdentityUserFlowId $b2xIdentityUserFlowId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
request_body = IdentityUserFlowAttributeAssignment(
is_optional = False,
requires_verification = False,
user_input_type = IdentityUserFlowAttributeInputType.TextBox,
display_name = "Shoe size",
user_attribute_values = [
]
user_attribute = IdentityUserFlowAttribute(
id = "extension_guid_shoeSize",
),
)
result = await graph_client.identity.b2x_user_flows.by_b2x_user_flow_id('b2xIdentityUserFlow-id').user_attribute_assignments.post(body = request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Location: https://graph.microsoft.com/v1.0/identity/b2xUserFlows/B2X_1_Partner/userAttributeAssignments/extension_guid_shoeSize
Content-Type: application/json
{
"id": "extension_guid_shoeSize",
"isOptional": false,
"requiresVerification": false,
"userInputType": "TextBox",
"displayName": "Shoe size",
"userAttributeValues": []
}