Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/idnet.dk/public_html/wp-includes/post-template.php on line 284

Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/idnet.dk/public_html/wp-includes/post-template.php on line 284

Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/idnet.dk/public_html/wp-includes/post-template.php on line 284

Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/idnet.dk/public_html/wp-includes/post-template.php on line 284

PowerShell and SharePoint REST – Unable to translate bytes from specified code page to Unicode

Intro

I recently had to transfer a large amount of CSV lines to a SharePoint list and decided that the PowerShell command Invoke-WebRequest and the SharePoint REST API would be a good match to get this done.

I build a PSObject for each CSV line as in

And then convert that to JSON when posting as in

Issue

Everything was going great until I hit some values containing the Danish characters æ,ø, and å. SharePoint threw a fit and returned the error

Solution

Use [System.Text.UTF8Encoding]  to get the bytes in UTF-8 encoding and post that

Hope this helps someone 🙂

 

You may also like...

1 Response

  1. Reinout says:

    It does! Thnx!

Leave a Reply

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