问题
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