Update B2C Custom Attribute String Collection via AD Graph API

Viewed 1682

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 Answers

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\"}"
Related