An organization unit is required for this action errorCode:1101

Hello everyone, I am trying to start a UiPath process from JS in Google Appscripts, but it is not working. Can someone help me? Please find below the code, but I have excluded sensitive information (IDs).

function createAndSendDocument() {
  // Make a POST request with a JSON payload.
var data = {  
  'client_id':'my client id',
  'refresh_token':my user key '
var options = {
  'method' : 'post',
  'contentType': 'application/json',
  'headers' : {'X-UIPATH-TenantName':'my tenant name'},  
  'payload' : JSON.stringify(data)
  var response = UrlFetchApp.fetch('', options);
  var jsonObject = JSON.parse(response.getContentText());
  var data2 = {    
   /* 'startInfo': {
    'ReleaseKey':'my process key',
        'startInfo': {
         'ReleaseKey':'my process key'',
          'InputArguments':'{\"param1\":\"Test Youtube Google\",\"param2\":\"Video Live 21:21\"}'
  var bear = 'Bearer '+jsonObject.access_token;
var options2 = {
  'method' : 'post',
  'contentType': 'application/json',
    'headers' : {'X-UIPATH-TenantName':'my tenant name', 'Authorization':bear,'X-UIPATH-OrganizationUnitId':'my org id'},  
  'payload' : JSON.stringify(data2)
  var response2 = UrlFetchApp.fetch(' id/tenant name/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs', options2); 

Exception: Request failed for returned code 400. Truncated server response: {“message”:“An organization unit is required for this action.”,“errorCode”:1101,“traceId”:“00-266fcedb261e5045b3fe9646fc32602c-7de4c5b3f51f8b27-01”} (use muteHttpExceptions option to examine full response)

What was the value you put for the X-UIPATH-OrganizationUnitId header? When you say ‘my org id’ did you mean the name of your automation cloud org?

Based on documentation the X-UIPATH-OrganizationUnitId header is meant to contain an integer value which is the ID number of the folder containing the process you would like to run. Example of a folder ID in my org is 152024.

Hi @Pedro_Reis_Prado

Welcome to the Community.

Would you please modify your code as per below-

var options2 = {
  'method': 'post',
  'contentType': 'application/json',
  'headers': {
    'X-UiPath-TenantName': 'my tenant name',
    'Authorization': bear,
    'X-UiPath-OrganizationUnitId': 'my org id'
  'payload': JSON.stringify(data2)

Ensure that you replace 'my org id' with the actual organization unit ID for your UiPath Orchestrator instance. You can find the organization unit ID in your Orchestrator settings.

Make sure to update the necessary values such as 'my tenant name', 'my org id', 'my process key', and other parameters with the correct values corresponding to your UiPath Orchestrator and process configuration.


Note: We recommend using instead of 'X-UIPATH-OrganizationUnitId' the 'FolderKey' header.

For accessing resources in a folder, each request must contain either the FolderId, FolderPath, or FolderKey in an HTTP header. This header may be encoded (using Base64 UTF-16LE encoding) or plain text.

For example:

  • X-UIPATH-OrganizationUnitId "FolderId",
  • X-UIPATH-FolderPath-Encoded "{Encoded FolderPath value}",
  • X-UIPATH-FolderPath "PlainText FolderPath value", or
  • X-UIPATH-FolderKey "FolderKey".

The FolderId can be obtained by performing a GET request to the /odata/Folders endpoint and copying the “Id” value, or from the Orchestrator URL - fid=2032 &tid=8. FolderId is of type Int 64.

The FolderKey can be obtained by performing a GET request to the /odata/Folders endpoint and copying the “Key” value. FolderKey is of type Unique Id/String.

If you change the licensing plan for your Orchestrator account (for example, from Enterprise Trial to Enterprise), the FolderId value also changes, whereas the FolderKey value remains the same.

If you upgraded and had Organization Units enabled in your previous Orchestrator instance, each OU is migrated as a new Classic folder.

Relative folder paths are supported in an X-UIPATH-FolderPath-Encoded header, as follows:

  • Path starting with / - starts from the root folder of the tree the ambient folder is part of.
  • Path starting with . - starts from the ambient folder.
  • Path starting with .. - starts one level up in the hierarchy of the ambient folder for each .. in the path (e.g. ../ for one level up, ../../ for two levels up in the hierarchy).

Note that trailing slashes are not accepted.


What is the solution to use when the call should not be made at the folder level?
With an endpoint like Releases, for example, it doesn’t make sense to get results for a folder.
What I really want to be able to do is reproduce the functionality of the a swagger authorized call to GET odata/Releases–which allows the X-UiPath-OrganizationUnitId to be omitted and returns results across the entire Automation Cloud tenant, but I want to do this using an external app in Orchestrator.

Check the below details (is the same for other endpoints)

Issue Description: Using Swagger docs, it is possible to retrieve all jobs via GET /odata/jobs. However, when this call is made via an external application, an error “An organization unit is required for this action” is thrown.

Why does it work in Swagger?
From Swagger, user context is considered, hence it works. When identified that a particular user context is used, it is possible to compute the folders in which there is access and it will be possible to fulfill the request.

It is recommended to not use cross-folder GETs as they might be impactful from a performance point of view. Hence it is recommended to stick with multiple API calls in specific folder contexts.

Why does not this work via a Bearer token generated via an external application?

External applications are used in the application context (not the user). In this case, specify a folder ID in the header ‘X-UiPath-OrganizationUnitId’.


It is recommended to use the X-UiPath-FolderKey key value in the headers section, instead of X-UiPath-OrganizationUnitId as is immutable.

Reference: Why The X-UIPATH-OrganizationUnitId Changed Automatically?

That answered my question thoroughly, thank you.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.