Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JakobGsvendsen
Frequent Visitor

REST API Injected data - special local letter do not show correctly.

Hello everyone

 

I am making a solution for a customer that grabs some data from a couple of REST web services using PowerShell.

then it injects to PowerBI using the PowerBI REST API.

 

To do this I am using this powershell wrapper/module:

https://github.com/DevScope/powerbi-powershell-modules

 

It works great! Except that the danish letters æ,ø,å does not show correctly.

 

1. I can see that my source data is correct, outputted in powerShell shows æ,ø,å correctly.

2. Module uses Invoke-RestMethod to send the data.

3. I have tried to set "charset"= "utf-8" in the headers for the sending of the data.

   'Content-Type' = 'application/json; charset=utf-8'

4. Data seems to show OK if I try to get something direct from a REST web service that also has æ,ø,å. (But I cannot use this method as the datasources does not support my other rest webservice.

 

but you see, they show like this:

https://user-images.githubusercontent.com/3460807/32954956-dcfdb1e6-cbb4-11e7-8441-a394eadd4170.png

 

I can confirn that it is not only the visual that does not show it, as I cannot make filters on data using any of the letters.

 

Does anyone know where this fails? and how to fix it?

 

 

1 ACCEPTED SOLUTION
JakobGsvendsen
Frequent Visitor

seems to be a powerShell issue for invoke-restmehtod and invote-websrequest as they cannot send as UTF8.

 

I have rewritten my powershell to make a call.

https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data-add-rows

 

Will send pull request to update the moduel asap, and then i hope he accepts 🙂

 

Prototype code (not pretty but works :)):

Function Invoke-PBIWebRequestPost {
param($Uri, $Headers,$Body)

  # Remove NewLine from json
  $Body = $Body -replace "$([Environment]::NewLine) *",""  

	write-verbose "Posting data to URL: $Uri"
    $request = [System.Net.WebRequest]::Create($uri) -as [System.Net.HttpWebRequest];
	$request.KeepAlive = $false;
	$request.Method = "POST";
	$request.ContentLength = 0;
    $request.TimeOut = 100000; #5 minute timout
	

	
            #Add token to the request header
            foreach($key in $headers.Keys)
            {

            switch($key){
            "Content-Type"{
                $request.ContentType = $headers[$key];
            }
            default {
                $request.Headers.Add($key, $headers[$key]);
            }
            }
          

            
            }

            
            $rowsJson = $Body

			$utf8Bytes = [System.Text.Encoding]::UTF8.GetBytes($Body)
			$request.ContentLength = $utf8Bytes.Length
			$postStream = $request.GetRequestStream()
			$postStream.Write($utf8Bytes, 0, $utf8Bytes.Length)
			#Write-String -stream $postStream -string $JSON
			$postStream.Dispose()
		
			try
			{
			  #[System.Net.HttpWebResponse] $response = [System.Net.HttpWebResponse] $request.GetResponse()
			  $response = $request.GetResponse()
			}
			catch
			{
			  $response = $Error[0].Exception.InnerException.Response; 
			  Throw "Exception occurred in $($MyInvocation.MyCommand): `n$($_.Exception.Message)"
			}
		
			$reader = [IO.StreamReader] $response.GetResponseStream()  
			$output = $reader.ReadToEnd()  
		
			$reader.Close()  
			$response.Close()
			return $output  
			
			

}

 

 

View solution in original post

1 REPLY 1
JakobGsvendsen
Frequent Visitor

seems to be a powerShell issue for invoke-restmehtod and invote-websrequest as they cannot send as UTF8.

 

I have rewritten my powershell to make a call.

https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data-add-rows

 

Will send pull request to update the moduel asap, and then i hope he accepts 🙂

 

Prototype code (not pretty but works :)):

Function Invoke-PBIWebRequestPost {
param($Uri, $Headers,$Body)

  # Remove NewLine from json
  $Body = $Body -replace "$([Environment]::NewLine) *",""  

	write-verbose "Posting data to URL: $Uri"
    $request = [System.Net.WebRequest]::Create($uri) -as [System.Net.HttpWebRequest];
	$request.KeepAlive = $false;
	$request.Method = "POST";
	$request.ContentLength = 0;
    $request.TimeOut = 100000; #5 minute timout
	

	
            #Add token to the request header
            foreach($key in $headers.Keys)
            {

            switch($key){
            "Content-Type"{
                $request.ContentType = $headers[$key];
            }
            default {
                $request.Headers.Add($key, $headers[$key]);
            }
            }
          

            
            }

            
            $rowsJson = $Body

			$utf8Bytes = [System.Text.Encoding]::UTF8.GetBytes($Body)
			$request.ContentLength = $utf8Bytes.Length
			$postStream = $request.GetRequestStream()
			$postStream.Write($utf8Bytes, 0, $utf8Bytes.Length)
			#Write-String -stream $postStream -string $JSON
			$postStream.Dispose()
		
			try
			{
			  #[System.Net.HttpWebResponse] $response = [System.Net.HttpWebResponse] $request.GetResponse()
			  $response = $request.GetResponse()
			}
			catch
			{
			  $response = $Error[0].Exception.InnerException.Response; 
			  Throw "Exception occurred in $($MyInvocation.MyCommand): `n$($_.Exception.Message)"
			}
		
			$reader = [IO.StreamReader] $response.GetResponseStream()  
			$output = $reader.ReadToEnd()  
		
			$reader.Close()  
			$response.Close()
			return $output  
			
			

}

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.