Unable to Fetch the Running Jobs in API Request

Hello

I just go throught swagger documentation, i tested in the swagger it works and shows the Running jobs, Same i used a python script to fetch the running jobs, getting error as
Jobs API Error:
{“message”:“A folder is required for this action.”,“errorCode”:1101,“traceId”:“00-6fe7e25f668fd641ffaf546fdaf02895-0676e391893c7da5-00”}
Same code, if i put the bearer token which i get from swagger, api work and shows running jobs.
I go through all the api documentation, get to know, for getting jobs, it requireds JOB.View permission, Actually i created external app and got client id and secret and enable all scopes in application section. Still the same. Also i added that application under manage access enable all items under jobs and added the application name under Modern Folder still the issue didn’t resolve. Any suggestion?

Hi @Abinash_Nagarajan,

The error “A folder is required for this action” indicates that the API request is missing the folder context.

Please try adding the Orchestrator folder ID in your Python API request header:


X-UIPATH-OrganizationUnitId: <Your_Folder_ID>

Also, please make sure that the external application has been assigned to the same folder and has the required Jobs → View permission.

The reason the Swagger bearer token works could be that Swagger automatically uses the selected folder context, while your Python request may not be sending the folder information.

Hope this helps! Please let us know if you are still facing the issue.

Hi @Abinash_Nagarajan,

It seems that the authentication is working, but the request is not getting the folder context. Since the Jobs API is folder-specific, please verify that your Python request includes the correct Orchestrator folder ID.

Also, compare the headers generated by Swagger with the headers sent from your Python script. The difference between them should help identify the missing configuration.

You can also share your API request headers (excluding the token and secret), and the community can help identify what is missing.

Thanks.

Hi @Abinash_Nagarajan ,
The issue is not with JOB.View permission. The Jobs API requires a folder context. When using your external app token, include the folder header in the request:
X-UiPath-FolderPath:
or

X-UiPath-OrganizationUnitId:

Also ensure the external application has access to that Modern Folder under Manage Access.
Thanks

Hi @Abinash_Nagarajan,

In Swagger, there’s a folder selector X-UIPATH-OrganizationUnitId header on mostly every request. Your Python script might not be sending that header, so Orchestrator rejects it even though the same bearer token works fine in Swagger.

Try to use these 2 headers in your python script.
headers = {
“Authorization”: “Bearer {token}”,
“X-UiPath-OrganizationUnitId”: “<folder_id>”
}

Or else you can straight away use the Orchestrator HTTP Request and get the running jobs through this API, if it’s not mandatory to use Python script.

I hope this helps.

Cheers!

Can you suggest how to get the modern folder id, because all our rpa process are subfolder of shared folder, i get the Shared folder id from swagger, API Works and return null.

Hi @Abinash_Nagarajan,

You can get all the folders like Shared, along with their subfolder ID’s through this API from Swagger.

Cheers!

For any api request in the modern folder you have to pass this parameter in the header.

X-UiPath-OrganizationUnitId

You can either call the another api request
{{BaseUrl}}/odata/Folders where BaseUrl is you orchestrator url to get the X-UiPath-OrganizationUnitId value or you can directly take it from the orchestrator url, your url might contains this parameter fid=123456 where 123456 is the that value

Hi @Abinash_Nagarajan,

You can get it from the Orchestrator URL. Open Orchestrator and select the Tenant. You will find the Folder ID (fId) in the URL.

Alternatively, you can use the Swagger → Get Jobs API. The OrganizationUnitId can be found in the response body.

Thanks!

Hello All

I get the Shared Folder id, when i use in api, it return empty. Because all my process are under shared as subfolder, Every subfolder has separate folder id. I need one api call to get fetch all running process. Is it possible?

Hi @Abinash_Nagarajan,

It seems you are using the Folder ID instead of the Organization ID. That’s why you are getting results only for that specific folder.

Thanks!

Hi @Abinash_Nagarajan

Hi, I think the issue is with the folder context rather than the JOB.View permission.
Since the same API works with the Swagger token, try passing the folder key in your Python API request:

X-UIPATH-FolderKey: <FolderKey>

You can get the FolderKey from the Folders API. Also make sure the external application has access to that specific folder.
Swagger may work because it already has the required folder context, while your Python request doesn’t.

How to get Organization ID?

Have a look at this.

You can get it from the Orchestrator URL. Open Orchestrator and select the Tenant. You will find the Folder ID (fId) in the URL.

Alternatively, you can use the Swagger → Get Jobs API. The OrganizationUnitId can be found in the response body.

If i use the Folder id which i get from Orchestrator tenant url, API return empty, also get shared folder id, it also returns empty.

You referring about tenant id right? i tried still it return empty.

it is like: fid=****** in the url.

Hi @Abinash_Nagarajan

The issue is most likely folder context, not permissions.

Swagger automatically sends the selected folder, but your Python API call may not. Try adding X-UIPATH-FolderKey (or X-UIPATH-OrganizationUnitId) with the correct folder value.

Also verify that the External App has access to that folder.

i used the fid, still returning empty