Does the Azure AD B2C Graph endpoint support UTF-8 charset for uploading policies?

Sean Killeen 321 Reputation points MVP

I have a custom policy XML document that contains characters that need UTF-8 to be rendered correctly (A country name of Curaçao)

When I manually run my CI scripts which use UTF-8 and upload the policy to Azure B2C's UI, I see the characters as expected.

However, despite reading the file using the UTF-8 encoding, when I call the endpoint for my PUT request, the resulting policy appears to not be rendered using UTF-8.

I have attempted the following for my content headers

  • $headers.Add("Content-Type", 'application/xml') -- the original, where I first saw the problem
  • $headers.Add("Content-Type", 'application/xml; charset=UTF-8') -- no change
  • $headers.Add("Content-Type", 'application/xml; charset="UTF-8"') -- 500 error from server
  • $headers.Add("Content-Type", 'application/xml; charset=utf-8') -- successfully completes, but no change; see the same issue

Any thoughts? I'm sure it must be something I'm missing.

The full powershell excerpt of what I'm doing:

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add("Content-Type", 'application/xml; charset=utf-8')
    $headers.Add("Authorization", 'Bearer ' + $token)

    $graphuri = '' + $PolicyId + '/$value'
    $policycontent = Get-Content $PathToFile -Encoding UTF8
    $response = Invoke-RestMethod -Uri $graphuri -Method Put -Body $policycontent -Headers $headers
Azure Active Directory External Identities
{count} votes

1 answer

Sort by: Most helpful
  1. Alfredo Revilla (Personal Account)) 376 Reputation points

    Hello @Sean Killeen , the code looks fine, just to be sure we're not missing anything try using the custom-policy-manager, which relies on MS Graph Beta too. If that fails then you need to raise an issue through B2C support.

    0 comments No comments