Robots scope still pulling folders

my code successfully pulls all the folders in Orchestrator but when I try to pull the Robots I still get Folders ?
could it be cause the authorize_token has some expiry time ?

the code for Folders and Robots is same except the scope

folder_payload = ‘grant_type=client_credentials&client_id=b8b50cd8bb&client_secret=#k#6jWJ&scope=OR.Folders’
robots_payload = ‘grant_type=client_credentials&client_id=b8b50b&client_secret=#J&scope=OR.Robots’

headers = {“Content-Type”: “application/x-www-form-urlencoded”}
conn.request(“POST”, “/identity_/connect/token”, robots_payload, headers)
res = conn.getresponse()
data = res.read()
res_dict = json.loads(data.decode(‘utf-8’))
authorize_token=res_dict.get(‘access_token’)

robots_url = ‘UiPath
robots_headers = {“Authorization”: f"Bearer {authorize_token}"}
robots_response = requests.get(robots_url, headers=robots_headers)
robots_response.raise_for_status()
robots_data = folders_response.json()[“value”]
print(json.dumps(robots_data, indent=2))

ok i am getting error on Robots url , what am I missing here? for Folders the url works fine

File “C:\Python392\lib\site-packages\requests\models.py”, line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: UiPath

@aliyesami

in modern folders get robots is deprecated. you need to use get users and under that you will have robots as well …

check swagger for more details

<OrchestratorURL/swagger/indexx.html

sample

also you are getting 400 may be because you did not provide organization unit…it is required for robots endpoint but even if you provide ideally no response would come as mentioned

cheers