I'm stumped on this one !
It started with running a TI process that would create a drill process for a certain cube, in an automated way. The TI process woud create a view and subsets, and the TM1 REST API is used to create the custom }Drill process. In the middle, in between TI and TM1 REST API, there is PowerShell to execute the REST API call. The drill stays within the same cube, for the sake of illustration: the drill consists of having all level 0 descendants of the chosen combination.
It works fine for regular cube names. However, as soon as the cube name contains accented characters, it breaks down.
In fact, there is quite some code but I narrowed it down to the below.
I have a code in PowerShell to call the REST API. The script grabs the body for the call from a text file.
If I use Postman to execute the REST API call, it all works perfectly even with a cubename that contains accents in the name. I merely copy/paste the text file contents, execute in Postman and the process is created.
However, executing the PowerShell script, manually, will after about 5 seconds also create a process, but the accented character is replaced / unknown / invisible.
Having said this, below are my codes to reproduce the issue. The code is as small as possible. With a few small steps / changes you can reproduce it on your system.
The cube is called 'Financiële rapportering', which is 'Financial reporting' in Dutch Please create that cube with dummy dimensions and also create a Default view.
Next, the text file contents of 'D:\test.txt':
Code: Select all
{
"Name": "test",
"HasSecurityAccess": true,
"DataSource": {
"Type": "TM1CubeView",
"dataSourceNameForServer": "Financiële rapportering",
"dataSourceNameForClient": "Financiële rapportering",
"view": "Default"
},
"Parameters": [],
"Variables": [],
"PrologProcedure": "\r\n\r\n",
"MetadataProcedure": "\r\n\r\n",
"DataProcedure": "\r\n\r\n",
"EpilogProcedure": "\r\n\r\n"
}
Code: Select all
$TM1User = "wim"
$TM1PW = "test"
$Secure_String_Pwd = $TM1PW | ConvertTo-SecureString -AsPlainText -Force
$TM1Password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Secure_String_Pwd))
$headers = @{"Authorization" = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($TM1User):$($TM1Password)"));}
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$body = Get-Content "D:\test.txt" -raw
$TM1_Instance_url = 'http://AEX199:8001/api/v1/Processes'
$TM1_create_process = Invoke-RestMethod -Method Post -uri $TM1_Instance_url -WebSession $session -Headers $headers -Body $body -ContentType "application/json"
If I execute the PowerShell file manually or through TI, it takes about 5 seconds. And still the datasource is not 'Financiële rapportering' but rather 'FinanciWRONG_CHARACTERle rapportering'
So I guess the questions center around:
- what happens when PowerShell calls the REST API such that it produces wrong characters ?
- what do others use to execute REST API scripts starting from TI ? Always Python and TM1py ?
Does anyone have a clue please ? Thanks !