I am trying to create a user using AAD B2C graph API. It is working fine when the Payload Json is English Character, but If I create the Json Payload with a Chinese character, Its fails.
Json Payload:
{
"passwordProfile": {
"password": "Abc1234@#",
"forceChangePasswordNextLogin": false
},
"signInNames": [
{
"type": "emailAddress",
"value": "[email protected]"
}
],
"accountEnabled": true,
"creationType": "LocalAccount",
"displayName": "林",
"mailNickname": "林",
"passwordPolicies": "DisablePasswordExpiration"
}
Error Details:
"Message": "One or more errors occurred. (Error Calling the Graph API: \n{\r\n \"odata.error\": {\r\n \"code\": \"Request_BadRequest\",\r\n \"message\": {\r\n \"lang\": \"en\",\r\n \"value\": \"Invalid value specified for property 'mailNickname' of resource 'User'.\"\r\n },\r\n \"requestId\": \"b2d0d3bf-394d-4ebd-a5b5-d905f1809c19\",\r\n \"date\": \"2019-02-15T06:55:06\",\r\n \"values\": [\r\n {\r\n
\"item\": \"PropertyName\",\r\n \"value\": \"mailNickname\"\r\n },\r\n {\r\n \"item\": \"PropertyErrorCode\",\r\n
\"value\": \"InvalidValue\"\r\n }\r\n ]\r\n }\r\n})"
Please help me to solve the issue.
You need to specify the mailNickname as specified by the error:
{
"givenName": "会话",
"surname": "宋",
"mail": "[email protected]",
"city": "TestCity",
"state": "hebei",
"country": "china",
"postalCode": "1245",
"mobilePhone": "12345678",
"mailNickname": "abc",
"accountEnabled": true,
"displayName": "displayname-here",
"passwordProfile": {
"password": "PasswordHere",
"forceChangePasswordNextLogin": true
},
"userPrincipalName": "[email protected]"
}
I've also included the other properties the documentation mentions are required.
You can see the reference here: https://learn.microsoft.com/en-us/previous-versions/azure/ad/graph/api/users-operations#create-a-user-work-or-school-account--