Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TM1.cells.write() Error with Elements containing german 'ß' #620

Closed
ubihw opened this issue Sep 29, 2021 · 5 comments
Closed

TM1.cells.write() Error with Elements containing german 'ß' #620

ubihw opened this issue Sep 29, 2021 · 5 comments
Labels

Comments

@ubihw
Copy link

ubihw commented Sep 29, 2021

Describe the bug

It looks like write_value() accepts 'ß' in element names, and write() does not.

To Reproduce

This one works:

>>> TM1.cells.write_value('READ','}ElementSecurity_KST',('Schließung 123','CAMID(":Firma:Gruppe1")'))
<Response [204]>

The value written is visible in Perspectives afterwards.

This one does not work:

>>> mycellset = {('Schließung 123','CAMID(":Firma:Gruppe1")'):'READ'}
>>> TM1.cells.write('}ElementSecurity_KST',mycellset)
Traceback (most recent call last):
  File "<pyshell#69>", line 1, in <module>
    TM1.cells.write('}ElementSecurity_KST',mycellset)
[...Traceback partly skipped...]
    raise TM1pyRestException(response.text,
TM1py.Exceptions.Exceptions.TM1pyRestException: Text: '{"error":{"code":"501","message":"\"SCHLIESSUNG123\" : Mitglied nicht gefunden (rte 81)"}}' - Status Code: 400 - Reason: 'Bad Request' - Headers: {'Content-Length': '120', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json; charset=utf-8', 'OData-Version': '4.0'}

Expected behavior

write() should accept element names containing 'ß', as write_value() does.

Version
TM1py 1.8
TM1 Server Version TM1-AW64-ML-RTM-11.0.94.24-0

@ubihw ubihw added the bug label Sep 29, 2021
@MariusWirtz
Copy link
Collaborator

Good catch! Thank you.

I traced this issue back to the mdxpy library. MDX statements are generated in all uppercase.
Somewhat surprisingly, the default upper() function in python turns the german character ß into SS.

We will adjust the mdxpy library to produce all lower case MDX queries.

@MariusWirtz
Copy link
Collaborator

For the moment, if your user has admin permissions I suggest you use the write function with the optional argument use_ti=True. It is the fastest way to write to TM1 from TM1py anyways.

from TM1py import TM1Service

with TM1Service(address="", port=12354, ssl=True, user="admin", password="apple") as tm1:
    cells = {
        ("Schließung", "e1"): 1,
        ("Schließung", "e2"): 2,
    }

    tm1.cells.write("c1", cells, use_ti=True)

MariusWirtz added a commit to cubewise-code/mdxpy that referenced this issue Sep 29, 2021
MariusWirtz added a commit to cubewise-code/mdxpy that referenced this issue Sep 29, 2021
MariusWirtz added a commit to cubewise-code/mdxpy that referenced this issue Sep 29, 2021
@MariusWirtz
Copy link
Collaborator

Can you please upgrade to the latest version of mdxpy and see if the fix resolved the issue?

pip uninstall mdxpy
pip install https://github.com/cubewise-code/mdxpy/archive/refs/heads/master.zip

@ubihw
Copy link
Author

ubihw commented Sep 29, 2021

Yes, now write() works as expected. Thank you for Nachtschicht :-)

@ubihw ubihw closed this as completed Sep 29, 2021
@MariusWirtz
Copy link
Collaborator

Gern geschehen :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants