cubewise-code / tm1py

TM1py is a Python package that wraps the TM1 REST API in a simple to use library.
http://tm1py.readthedocs.io/en/latest/
MIT License
189 stars 109 forks source link

Unable to get all cube names #1111

Closed donlim93 closed 6 months ago

donlim93 commented 6 months ago

Here is the script I ran to get the server version and all of the cube names:

from TM1py.Services import TM1Service

params = {
    "base_url": "https://[XXXXXX].planning-analytics.cloud.ibm.com/tm1/api/dev1_tm1/",
    "user": "[Non-interactive account username]",
    "password": "[Non-interactive account password]",
    "namespace": "LDAP",
    "async_requests_mode": True,
    "ssl": True,
    "verify": True,
}

with TM1Service(**params) as tm1:
    print(tm1.server.get_product_version())
    c = tm1.cubes.get_all_names()
    print(c)

I received the following output:

11.8.02300.10
[]

If I try to get a specific cube, such as a 'Planning' cube

with TM1Service(**params) as tm1:
    c = tm1.cubes.get("Planning")

I receive the following output:

Traceback (most recent call last):
  File "c:\Users\[USERNAME]\Downloads\tm1py-samples-master\Metadata\cube_get.py", line 31, in <module>
    c = tm1.cubes.get("Planning")
        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[USERNAME]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\TM1py\Services\CubeService.py", line 45, in get
    response = self._rest.GET(url=url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[USERNAME]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\TM1py\Services\RestService.py", line 500, in GET
    return self.request(
           ^^^^^^^^^^^^^
  File "C:\Users\[USERNAME]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\TM1py\Services\RestService.py", line 324, in request
    self.verify_response(response=response)
  File "C:\Users\[USERNAME]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\TM1py\Services\RestService.py", line 889, in verify_response
    raise TM1pyRestException(response.text,
TM1py.Exceptions.Exceptions.TM1pyRestException: Text: '{"error":{"code":"278","message":"'Planning' can not be found in collection of type 'Cube'."}}' - Status Code: 404 - Reason: 'Not Found' - Headers: {'Content-Length': '107', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json; charset=utf-8', 'OData-Version': '4.0'}

Version TM1py version: 2.0.2 TM1 server version: 11.8.02300.10 Pandas version: 2.2.2

nicolasbisurgi commented 6 months ago

Hi @donlim93 - have you checked that the non-interactive account has ADMIN rights? tm1.security.is_admin property should tell you right away.

donlim93 commented 6 months ago

That was it. Thanks for the quick reply and your help.