comparing tm1py authentication method with postman commands

276 Views Asked by At

I successfully used tm1py package and was able to get the cubes information using below code.

from TM1py.Services import TM1Service

with TM1Service(address= "localhost",port="51130",user= "pm",password= "IBMDem0s",namespace="Harmony LDAP",ssl= False) as tm1:
    df =tm1.cubes.cells.execute_view_dataframe(cube_name ="PUR_Sales_Planning",view_name="View1",private= False)

Now I need to check the same thing using Postman commands. I tried https://code.cubewise.com/blog/mastering-the-tm1-rest-api-with-postman to test that

.So I used Authorization Type as 'Basic Auth'.User name as pm,password as IBMDemos.And the URL as follows.http://localhost:51130/api/v1/Cubes (I just need all the cube names).

But I got an error from postman '401 Unauthorized'.Can anyone advise what has gone wrong here.Do I need to enter namespace name field in somewhere in postman.

2

There are 2 best solutions below

1
Wuzardor On

Did you try https instead of http? Because for me when I tried your example on postman I use HTTPS and it works for me. And in the example it's HTTPS too.

Moreover you have to put the servername of the server where your TM1server is (instead of localhost). After you have to put the httpportnumber entered in your tm1s.cfg file.

Here is an exemple: https://'servername':'httpportnumber'/api/v1/Cubes

Please let me know how you handle with it.

0
EAA On

Since you are providing namespace in TM1py example, I guess, you are using CAM security.

Postman.
In Authorization tab set Type to 'No Auth'. Set the following Authorization header:

CAMNamespace base64(user:password:namespace)

In your case the string will look like so:

CAMNamespace cG06SUJNRGVtMHM6SGFybW9ueSBMREFQ

Now you can execute the query.

References:
https://www.ibm.com/docs/en/planning-analytics/2.0.0?topic=api-authenticating-managing-sessions
https://www.base64encode.org/