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

Sean Killeen 351 Reputation points MVP
2021-03-13T19:20:00.66+00:00

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 graph.microsoft.com/beta/trustframework/policies/ 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 = 'https://graph.microsoft.com/beta/trustframework/policies/' + $PolicyId + '/$value'
    $policycontent = Get-Content $PathToFile -Encoding UTF8
    $response = Invoke-RestMethod -Uri $graphuri -Method Put -Body $policycontent -Headers $headers
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,633 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alfredo Revilla (Personal Account) 391 Reputation points
    2021-10-20T14:57:01.467+00:00

    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