Skip to main content
In Pycelonis , when I had used get_celonis i got permission error , so I need to know how can I tackle these error.

Without more context thats hard to answer.

Firstly it is super different if you are using PyCelonis from within MLWB or from somewhere outside of Celonis.

Only within MLWB

celonis = get_celonis() works out of the box.

Otherwise you can pass in the get_celonis a lot of different paramters.

I would create an API Token for your useraccount and use this one to establish connection.

by passing in url, api token and key type.

 

celonis = get_celonis(base_url=<your url>,

                                  api_token=<Token you created,

                                  key_type="USER_KEY")

 

Potentially even a proxy could be needed with proxies=... but that totally depends on your setup.

 

It is worth to mention, that the USER key should only be used for development phase and switched out with an application key once moving more into production.

 

Check this tutorial: https://celonis.github.io/pycelonis/2.4.0/tutorials/executed/01_quickstart/02_celonis_basics/?h=get_celonis%28%29#12-connect-to-the-ems

 

 


Hi Ankit,

1)First of all check the pycelonis version using the below code:

!pip show pycelonis.

2)If your version is below 2 run the below code:

from pycelonis import get_celonis

celonis = get_celonis(url='team_url', key_type='APP_KEY', permissions=False)

3)If your version is above 2 run the below code:

from pycelonis import get_celonis

celonis = get_celonis(permissions = False)

 

Thanks,

Akshay


Hello akshay ,

thanks for your solution . Can you please tell me for new version which attribute should i used for api request and find a data pools ?

 


Hi Ankit,

1)I think your question is regarding how we can install new pycelonis version ,for that you can first uninstall the existing version using the code !pip uninstall pycelonis and then install the latest pycelonis version, for eg: if you need pycelonis 2.5.0 you can use !pip install pycelonis=="2.5.0",make sure you have only one pycelonis version installed otherwise it may cause circular import error when ever you trigger any python code.

 

2)a)For listing out dps in your code you can use the below code:

from pycelonis import get_celonis

celonis = get_celonis(permissions = False)

 

for dp in celonis.data_integration.get_data_pools():

   print(dp.name)

 

b) And then if you want to import specific dp from that list you can use the below code:

data_pool = celonis.data_integration.get_data_pools().find("datapool_name")

 

 

Thanks,

Akshay

 

 


Hello Akshay,

I had already updated pycelonis new version 2.6.0 .previous version when i was fetching kpi that time i was use api_request .but new version i unable to fetch api because throw error celonis object has no attribute api request and if i fetch any url then throw celonis has no attribute url. So my question is can you please tell me new how i can use url

and api_request.

 

Thanks,

Ankit


Hi Ankit,

In the new version of pycelonis ,if you want to use api functionalities (get,post,upsert,delete) firstly you have to install certain python packages such as json and requests. You can use the code !pip install json and !pip install requests. After that you can use the below code. For eg: you are performing a get operation to retrieve data from a specific end point and you want to print the json file response.

 

from pycelonis import get_celonis

import json

import requests

 

celonis = get_celonis(permissions = False)

response = celonis.client.request("GET", "add your api end point here")

jsondict = json.loads(response)

print(jsondict)

 

Thanks,

Akshay

 

 


Hello Akshay, 

url = f"{c.url}/integration//api/pools/data-consumption/?limit=5000&page={page}&sort=consumptionInBytesZA"

consumption_table = c.api_request(url, message = 'None', method = 'GET', get_json = True)

From above mention code I got error : AttributeError: 'Celonis' object has no attribute 'url'

Can Please help if url has no attribute new version of 2.6 then which attribute i have to use for running these code .

 

Thanks & Regards,

Ankit


Hi Ankit,

Please try the below code:

from pycelonis import get_celonis

import requests

 

c = get_celonis()

url = f"{c.url}/integration//api/pools/data-consumption/?limit=5000&page={page}&sort=consumptionInBytesZA"

consumption_table = c.client.request("GET",url)

 

 

 

 


Hello Akshay

 

def get_consumption_df(c):

  page = 0

  df=pd.DataFrame()

   

  # Iterate over pages of data consumption

  while True: # while true + if -> break 

    url = f"{c.url}/integration//api/pools/data-consumption/?limit=5000&page={page}&sort=consumptionInBytesZA"

    consumption_table = c.client.request("GET",url)

    t_list = consumption_table_"extendedTableConsumptionTransports"]

    if len(t_list) == 0:

      # Reached last page: no more data

      break

    df = pd.concat(Âdf,pd.DataFrame(t_list)])

    page += 1

    # Limit api request rate

    time.sleep(1)

  return df

 

df_consumption_ = get_consumption_df(c)

 

when I have run with function then I got same error AttributeError: 'Celonis' object has no attribute 'url'

 


Hi Ankit,

Instead of setting the url as a variable directly pass it in the call, for eg:

consumption_table = c.client.request("GET","{c.url}/integration//api/pools/data-consumption/?limit=5000&page={page}&sort=consumptionInBytesZA")

 

NB: if {c.url} variable has a url in it then you have to replace it in the api call you are making. for example if c.url = "https://sample/" then in the api call you have to replace it as

consumption_table = c.client.request("GET","https://sample/integration//api/pools/data-consumption/?limit=5000&page={page}&sort=consumptionInBytesZA")").

 


Hello Akshay

 

def get_consumption_df(c):

  page = 0

  df=pd.DataFrame()

   

  # Iterate over pages of data consumption

  while True: # while true + if -> break 

   consumption_table = c.client.request("GET","{c.url}/integration//api/pools/data-consumption/?limit=5000&page={page}&sort=consumptionInBytesZA")

    t_list = consumption_table "extendedTableConsumptionTransports"]

    if len(t_list) == 0:

      # Reached last page: no more data

      break

    df = pd.concat( df,pd.DataFrame(t_list)])

    page += 1

    # Limit api request rate

    time.sleep(1)

  return df

 

df_consumption_ = get_consumption_df(c)

 

when I was running these code then I got error TypeError: 'Response' object is not subscriptable

can you please tell me how to tackel these error


Hy Ankit,

 

Try installing json in your workbench using !pip install json and then import the module in your code using import json and then try running the code.


Hi Akshay,

I had alredy install json but still i have facing these error .

 


Hi Ankit ,

Hope you have imported json in your code using import json , and after that try to replace this part of your code t_list = consumption_table["extendedTableConsumptionTransports"] with the below code:

 

t_list = consumption_table.json())'extendedTableConsumptionTransports']

 


Hello Akshay ,

Can you please help me out how to pull all data job logs information like extraction and transformation and make data frame .

Thanks In advance .


Hi Ankit,

In order to retrieve logs of your dj's there are certain requirements initially:

The url to your datajobs logs that you could find out by going to your dp -> rightclick->inspect->network->datajobs

 

 

code:

from pycelonis import get_celonis

import pandas as pd

import json

import requests

path = "The path were you need to save the csv"

df_to_csv_mode = True

 

celonis = get_celonis(permissions = False)

response = celonis.client.request("GET","URL to which the API request is to be send(which I have mentioned as requirements in the beginning")

json = json.loads(response.text)

Logs_df = pd.DataFrame(json)

 

if df_to_csv_mode:

  Logs_df.to_csv(path + '/name_of_the_csv.csv', encoding='utf-8', index=False)


Hello Akshay

json = json.loads(response.text)

 

here i got error

use this code i got error JSONDecodeError: Expecting value: line 1 column 1 (char 0)

 


Hello Akshay

json = json.loads(response.text)

 

here i got error

use this code i got error JSONDecodeError: Expecting value: line 1 column 1 (char 0)

 

Hi Ankit,

The error you are encountering is because you are trying to decode an empty or invalid json string , you are trying to parse a json response that is empty or not properly formatted . So please check the url you are using.


Hello Akshay ,

I have used in celonis logs url, so can you please tell me in celonis logs url in which fromat

 


Hi Ankit,

It would be in this kind of a format :

https://your_EMS_url_here/api/members?includeInternal=true


Reply