Microsoft Graph, JSON und Umlaute

Ergebnisse aus Anfragen an Microsoft Graph liefert es meist im JSON-Format zurück. In den Ergebnissen werden Umlaute, Sonderzeichen oder andere Zeichen oft nicht korrekt dargestellt.

Für die Lösung gibt es zwei Optionen. In einigen Fällen ist die erste Option ausreichend, in anderen Fällen benötigt ihr beide Optionen.

1. Gebt den Zeichensatz im ContentType mit.

Invoke-RestMethod -Uri $MSGraphUrl -Headers $AuthHeader -Method Get -ContentType 'application/json; charset=utf-8'

Es können weiterhin Umlaute falsch dargestellt werden.


2. Enkodiert das Ergebnis aus MSGraph mit dem korrekten Zeichensatz.

$MSGraphResults = Invoke-RestMethod -Uri $MSGraphUrl -Headers $AuthHeader -Method Get -ContentType  'application/json; charset=utf-8'  
$EncodedResults = [Text.Encoding]::UTF8.GetString([Text.Encoding]::GetEncoding(28591).GetBytes($MSGraphResults))
Share
Avatar photo

Tobias Asböck

Tobias is a Senior System Engineer with more than 10 years of professional experience with Microsoft 365 products such as SharePoint Online, SharePoint Premium, OneDrive for Business, Teams Collaboration, Entra ID, Information Protection, Universal Print, and Microsoft 365 Licensing. He also has 15+ years of experience planning, administering, and operating SharePoint Server environments. Tobias is a PowerShell Scripter with certifications for Microsoft 365 products. In his spare time, Tobias is busy with updates in the Microsoft 365 world or on the road with his road bike and other sports activities. If you have additional questions, please contact me via LinkedIn or [email protected].

Leave a Reply

Your email address will not be published. Required fields are marked *