无法使用具有中文字符Json数据的Azure Active Directory B2C图形API创建新用户

5f0d552i  于 2023-08-07  发布在  其他
关注(0)|答案(1)|浏览(104)

我正在尝试使用AAD B2C图形API创建用户。当Payload Json是英文字符时,它工作正常,但如果我用中文字符创建Json Payload,它就会失败。
Json Payload:

{
  "passwordProfile": {
    "password": "Abc1234@#",
    "forceChangePasswordNextLogin": false
  },
  "signInNames": [
    {
      "type": "emailAddress",
      "value": "abc@gmail.com"
    }
  ],
  "accountEnabled": true,
  "creationType": "LocalAccount",
  "displayName": "林",
  "mailNickname": "林",
  "passwordPolicies": "DisablePasswordExpiration"
}

字符串

错误详情:

“消息”:“发生了一个或多个错误。(调用图形API时出错:\n{\r\n \“odata.error":{\r\n \“代码":\“Request_BadRequest",\r\n \“message":{\r\n \“lang":\“en",\r\n \“value":\“为资源“User”的属性“mailNickname”指定的值无效。"\r\n },\r\n \“requestId":\“b2 d 0 d3 bf-394 d-4 ebd-a5 b5-d905 f1809 c19",\r\n \“日期":\“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})
请帮我解决这个问题。

inb24sb2

inb24sb21#

您需要指定错误所指定的mailNickname:

{
  "givenName": "会话",
  "surname": "宋",
  "mail": "abc@gmail.com",
  "city": "TestCity",
  "state": "hebei",
  "country": "china",
  "postalCode": "1245",
  "mobilePhone": "12345678",
  "mailNickname": "abc",
  "accountEnabled": true,
  "displayName": "displayname-here",
  "passwordProfile": {
    "password": "PasswordHere",
    "forceChangePasswordNextLogin": true
  },
  "userPrincipalName": "abc@gmail.com"
}

字符串
我还包括了文档中提到的其他必需属性。
你可以在这里看到参考:https://learn.microsoft.com/en-us/previous-versions/azure/ad/graph/api/users-operations#create-a-user-work-or-school-account--

相关问题