Skip to main content
Solved

How to perform a GET request from the ML Workbench?

  • August 26, 2024
  • 4 replies
  • 52 views

miguel.ferna11
Level 3
Forum|alt.badge.img+13

The idea is to have a script that automatically downloads a json file with the list of members of the Celonis environment through the Members API (/api/external/members).

 

I have the following code:

 

url = ""

api_token = ""

key_type = "AppKey"

 

headers = {

key_type: api_token,

'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',

  'Body-Type': 'application/json',

'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7'

}

response = requests.get(url=url, headers=headers)

 

This code always returns <Response [403]> (Access denied). However, the api key I'm using works perfectly in the Swagger UI webpage, being able to download the json file without any problems.

 

I wrote a ticket to Celonis support and they told me it's possible to perform a GET request, but I can't seem to find a way to do it.

Best answer by mateusz.dudek14

Hi,

 

Use built-in function for pycelonis - you'll avoid Authentification headache :)

 

Code:

from pycelonis import get_celonis

import pandas as pd

 

celonis = get_celonis(permissions=False)

response = celonis.client.request(url=celonis.client.base_url + '/api/members?includeInternal=true', method='GET')

usersJson = json.loads(response.text)

usersDf = pd.DataFrame(usersJson)

usersDf['groups'] = usersDf['groups'].astype(str)

 

 

My old post that may solve potential problems: Celonis user list data upload with PyCelonis 2.0+ (2.6.0) (celopeers.com)

 

Best Regards,

Mateusz Dudek

4 replies

mateusz.dudek14
Level 11
Forum|alt.badge.img+11
  • Level 11
  • 102 replies
  • Answer
  • August 28, 2024

Hi,

 

Use built-in function for pycelonis - you'll avoid Authentification headache :)

 

Code:

from pycelonis import get_celonis

import pandas as pd

 

celonis = get_celonis(permissions=False)

response = celonis.client.request(url=celonis.client.base_url + '/api/members?includeInternal=true', method='GET')

usersJson = json.loads(response.text)

usersDf = pd.DataFrame(usersJson)

usersDf['groups'] = usersDf['groups'].astype(str)

 

 

My old post that may solve potential problems: Celonis user list data upload with PyCelonis 2.0+ (2.6.0) (celopeers.com)

 

Best Regards,

Mateusz Dudek


miguel.ferna11
Level 3
Forum|alt.badge.img+13
  • Author
  • Level 3
  • 4 replies
  • August 28, 2024

Hi,

 

Use built-in function for pycelonis - you'll avoid Authentification headache :)

 

Code:

from pycelonis import get_celonis

import pandas as pd

 

celonis = get_celonis(permissions=False)

response = celonis.client.request(url=celonis.client.base_url + '/api/members?includeInternal=true', method='GET')

usersJson = json.loads(response.text)

usersDf = pd.DataFrame(usersJson)

usersDf['groups'] = usersDf['groups'].astype(str)

 

 

My old post that may solve potential problems: Celonis user list data upload with PyCelonis 2.0+ (2.6.0) (celopeers.com)

 

Best Regards,

Mateusz Dudek

Hi Mateusz,

 

Thanks so much for your answer! When executing your code I get this error:

 

PyCelonisPermissionError: You don't have permission to perform 'GET' ->

 

I thought the problem was the Api Key and its permissions, but doing celonis = get_celonis(permissions=False) that shouldn't be an issue. Also the ML Workbench user has both Team and User Provisioning permissions.

 

Kind regards.


mateusz.dudek14
Level 11
Forum|alt.badge.img+11

Hi Mateusz,

 

Thanks so much for your answer! When executing your code I get this error:

 

PyCelonisPermissionError: You don't have permission to perform 'GET' ->

 

I thought the problem was the Api Key and its permissions, but doing celonis = get_celonis(permissions=False) that shouldn't be an issue. Also the ML Workbench user has both Team and User Provisioning permissions.

 

Kind regards.

Definitely permission issue, same code works on my side - I'm always giving permissions directly to the app, not the API key, and giving full permissions also to users and teams categories:

 

imageimageimageBest Regards,

Mateusz Dudek


miguel.ferna11
Level 3
Forum|alt.badge.img+13
  • Author
  • Level 3
  • 4 replies
  • August 29, 2024

Hi Mateusz,

 

Thanks so much for your answer! When executing your code I get this error:

 

PyCelonisPermissionError: You don't have permission to perform 'GET' ->

 

I thought the problem was the Api Key and its permissions, but doing celonis = get_celonis(permissions=False) that shouldn't be an issue. Also the ML Workbench user has both Team and User Provisioning permissions.

 

Kind regards.

That was it, yeah. I've given a few more permissions to the workbench app and now the script works like a charm.

 

Thanks so much!