Global AI and Data Science

Global AI & Data Science

Train, tune and distribute models with generative AI and machine learning capabilities

 View Only
  • 1.  TM1py API Call

    Posted Tue November 05, 2024 03:10 PM

    I am trying to test an API connection to TM1 using the TM1py library in Python. I believe I have everything configured, per my welcome kit, however I keep getting the following error. I do not see a token mentioned anywhere in my welcome kit, so I am unsure where to go from here. Any advice?

    Failed to connect to TM1 server: Text: '{ "error":"access_denied", "error_description":"Failed to verify OAuth information. Transaction ID=60786123" }' - Status Code: 401 - Reason: 'Unauthorized' - Headers: {'Date': 'Tue, 05 Nov 2024 16:48:39 GMT', 'Server': '', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'Content-Type': 'application/json', 'WWW-Authenticate': 'Bearer', 'X-Backside-Transport': 'FAIL FAIL', 'Vary': 'Accept-Encoding', 'Content-Encoding': 'gzip', 'X-Content-Type-Options': 'nosniff', 'Content-Length': '118', 'Keep-Alive': 'timeout=5, max=100', 'Connection': 'Keep-Alive'}

    This is my code, with credentials nullified. 

    from TM1py import TM1Service
    from TM1py.Objects import Process
    from TM1py.Exceptions import TM1pyException

    # Connection details
    config = {
        "address": "",
        "port": "",
        "user": "",
        "password": "",
        "namespace": "",  
        "ssl": True  
    }


    try:
        # Establish a connection
        with TM1Service(**config) as tm1:
            print("Connection to TM1 server was successful!")

    except TM1pyException as e:
        print(f"Failed to connect to TM1 server: {e}")



    ------------------------------
    Peter Lombardo
    ------------------------------


  • 2.  RE: TM1py API Call

    Posted Wed November 06, 2024 02:38 AM

    Hi Peter,

    I assume you are using PA Cloud as you are referring to the Welcome Kit?

    In that case you need to pass:

    • base_url
    • namespace: LDAP
    • user
    • password
    • ssl: true
    • verify: true
    • async_request_mode: true

    The user/password should be the credentials of your non-interactive user account.

    The base url should be something like "https://<environment>.planning-analytics.cloud.ibm.com/tm1/api/<database instance>"

    Kind regards,

    Luc



    ------------------------------
    Luc Cusiel
    ------------------------------