Update B2C Custom Attribute String Collection via AD Graph API

不打扰是莪最后的温柔 提交于 2019-12-24 03:40:25

问题


Can I define a custom attribute whose data type is stringCollection and update it via the Azure AD Graph API? My experiment is failing:

The request body contains unexpected characters/content for the specified content type and encoding


Custom Attribute Definition

<ClaimType Id="extension_array_test">
    <DisplayName>Array Test</DisplayName>
    <DataType>stringCollection</DataType>
    <UserHelpText>Array Test in Token</UserHelpText>
</ClaimType>  

Using the Graph API Sample client

{
    "extension_[my-guid]_array_test": ["value 1", "value 2"]
}

Error Calling the Graph API:
{
  "odata.error": {
    "code": "Request_BadRequest",
    "message": {
      "lang": "en",
      "value": "The request body contains unexpected characters/content for the specified content type and encoding."
    }
  }
}

回答1:


The second note in the documentation you provided states extension attributes currently only support the string data type.

As an alternative you could store your data as escaped JSON like this:

"extension_{GUID}_JsonAttribute": "{\"Item1\":\"Test\",\"Item2\":\"Data\"}"


来源:https://stackoverflow.com/questions/47418132/update-b2c-custom-attribute-string-collection-via-ad-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!