1st part is a background process which connects to sharepoint, reads a file and based on the criteria(based on the data in SP file), it will trigger process no.2( which is UI automation process) which need to run on same machine/VM.
The 1st process runs on a scheduled trigger mode, since it runs a VM, it creates a session with the configured robot account.
the moment it calls the activity “Run Job” it throws a System.Exception: You are not authorized! Error code: 0
checks done so far:
1.env variable on VM : “UiPath_headless_wtih_user” is set to true.
2. robot has access to View, Edit, Create [Processes, jobs, Connections]
Can you share abit more about your studio version and licence, the Orchestrator setup (on prem / cloud) and the version of the activities you are using?
If its on prem then this could make sense, aswell as trying to do this on a community licence.
2nd process is developed on Studio and the packages are :
UiPath.Excel.Activities = 2.24.3
UiPath.MicrosoftOffice365.Activities = 2.7.24
UiPath.System.Activities.Runtime = 24.10.4
UiPath.UIAutomation.Activities.Runtime = 24.10.0
UiPath.WebAPI.Activities.Runtime = 1.21.1
1st process invokes Run Job Activity which has the 2nd process name (Both are in the same folder).
i’ve also set the following :
Execution mode : DO NOT WAIT
Machine name : I’m passing this dynamically and i have left the account name as empty so that the robot uses the default account configured to the Machine.
Cool, that setup looks good then.
Have you debugged that you are getting the machine name correctly? Does the code work if you dont specify a machine name?
Does this work when debugging in Studio Web? Might be harder to test as I guess you need to add the other process to your personal workspace.
Tested both processes separately, both are being triggered successfully in unattended mode on the same machine, when run separately.
its a bit tricky to test it on my dev environment as we don’t configure any unattended runtimes in that, i can test it on my QA env and see..
I do have a doubt about the machine name that I’m passing dynamically.
Should I pass the exact name of the machine template as defined? i’m actually passing the name of the VM(which is not exactly equal the template name defined).
This is likely the issue. You pass the Machine Template from what I see in the activity. Seems like a bad error is being returned thats misleading, but you are setting the wrong machine template by passing the Host Name
hello again
I tried passing the exact machine template name in the machine name value but no luck..
I do see a series of application events generated on the host :
1.
UiPath.Service.Host 24.10.6.0
Media Capture not supported for headless jobs.
UiPath.Service.Host 24.10.6.0
System.UnauthorizedAccessException: Could not obtain access token. (invalid_scope)
UiPath.Service.Host 24.10.6.0
Executor_1724 7460828 IExecutorContract GetAccessToken 4. # System.UnauthorizedAccessException: Could not obtain access token. (invalid_scope)
UiPath.Executor.NetCore 24.10.6.0
RemoteException wrapping System.UnauthorizedAccessException: Could not obtain access token. (invalid_scope)
Only thing that comes to my mind is if this has something to do with sharing the windows session that my first robot has created.
I dont think this can be achieved the way you are trying to as on the same machine also, background service and foreground service both uses different host identity to create a session on the machine.
Please do below test and verify..
run your backrgound process and foreground process separately from orchestrator on same machine.
then view the logs and check the value of host identity. I am sure that will be different for both processes even though you may specify a certain set of bot creds while creating the trigger.
Background service doesn’t create a full fledged session on the machine like foreground service so it doesn’t have required authorities to do operations like foreground process.
Thanks for responding, Sonali..
my 2 processes are dependent processes meaning, the run Criteria is separated in the 1st process and based on the outcome of the 1st process, the 2nd process is to be triggered. so i cannot run separately.
Yes, background jobs, in general run using LocalService a/c but i have modified the setting to use the same Login creds that the VM is configured with. so that both processes run using same credentials.
I tried running them separately after this and host identity is same for both(Creds that are configured for the machine).
Just wondering if UiPath has the capability like PowerAutomate cloud flow wherein, we can segregate processes that can run on cloud and processes that need a VM to run.
Background processes use windows session 0 and local machine to run that is the permissions given to the user might not apply..may be that is causing the unauthorized issue
For now ..if you want to run on same machien then as per docs its better use run prallel process activity so it starts on same user
Run job on other hand tries to call api using robot creds but robot creds for session 0 are local at user which might not be able to call the start job api and hence its failing
I dont think this is related at all to it being a background process to be honest, the permissions on the machine are irrelevant as its the same robot running it in foreground or in the background when it comes to Orchestrator API’s.
I routinely use that activity, from a background process in session zero, and don’t have an issue. My main difference is that I dont ever specify the machine and just let it run where-ever is configured (not sure why the machine needs to be the same to be honest).
As such, I feel like the machine name is the issue, its being entered wrong and triggering an incorrect error message.
The other difference of note, is the studio web process in cross platform, I usually use Windows, but I’d be surprised of an error there, but worth checking.
After alot of combinations and testing, i was able to finally achieve what i was looking for!
so the issue is that I have supplied only “machine name” for Run Job activity, but when i supplied Machine name and Robot Account, it worked!
looks like the combination is the only way that it works.
I need both processes to run on same machine, as the access to the sharepoint and n/w drive is provisioned only to the bot account.
I have also tested running in unattended mode with session 0 as well as the account that is configured to the VM, both worked.
So finally this is my robot configuration finally :
1.Time based trigger is setup on my 1st robot and it runs as session 0 process.(this still consumes my unattended runtime license- i was assuming this would work like cloud flow in power automate may be there’s a different type of license in UiPath for that)
2.1st robot reads the file on SP, checks the criteria and if the criteria is satisfied, it calls my 2nd robot(foreground bot), on the same VM.
3. since i passed a combination of machine/VM name and robot account to the “run job” activity, it successfully triggered the job for 2nd process on the same machine/VM and with the same robot account that i configured.
Sounds like you always needed the robot account AND the machine name as a different robot account on the same machine might not have the same network drives etc.
Thanks for sharing the solution and good to know it for some reason wants both. I feel like thats a bug.
@loginerror Hello Maciej, in the latest run job activities I think there is an unintended bug, where you cannot specify only the machine template to run the job on, and it gives a misleading error when you do.
I don’t see any explanation of this in the documentation (Appears that the machine and account configuration are not detailed at all there).
(Activities - Run Job)
If its intended behaviour, I’d suggest a better error and/or validation in the activity card that means if you select just the machine it informs you that you must also select an account, however my guess is its unintended right?
@golla.sandeep You have one of the top/best UiPath guys investigating this for you. Since he cannot reproduce it himself, perhaps you can share some good quality detail here?
I know you explained already, but if you can sumarise again.
The project types (so Studio web etc), where they are published and running, how you have the Run Job activity configured and the dependencies used, plus screenshots where appropriate to make it clearer.
If UiPath can reproduce it, they’ll fix it for everyone! If they can’t… well… I dunno how you created this error
Project setup :
Basically a 2 part solution where the 1st robot is built with Studio Web(background process) and 2nd with Studio(foreground process).
Details: 2nd solution is developed long back and has been running everyday based on time trigger, now the schedule needed a change where project teams would decide which day and time to run along with some other criteria. so, instead of disturbing the existing solution / setting up manual triggers / running the robot in adhoc mode whenever they need, they agreed to define when to run in an excel file and place it on SharePoint site. The 1st robot that I made is to read the run schedule and some other criteria and trigger the 2nd robot accordingly.
1st process reads the file on SP and based on the criteria it invokes the 2nd robot using “Run Job Activity”.
parameters for Run Job Activity :
Process Name : Passed as input argument
Execution mode : DO NOT WAIT
Machine name : Passed as input argument
Robot Name : NOT SPECIFIED (so that the [robot] uses the default account configured to the Machine)
deployment : (Both are under the same orchestrator folder, basically the solution contains both processes, assets, connections etc)
Outcome of a couple of tests with above setup :
Started(with unattended runtime) the 1st robot(in background) to run in session 0 but it failed to invoke the 2nd robot with exception :
Raw message: You are not authorized! Error code: 0 System.Exception: You are not authorized! Error code: 0 at UiPath.Activities.System.Jobs.RunJob.JobFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom) at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
Changed the system environment variable “UiPath_headless_with_user” to TRUE and triggered again but failed with same exception as above but this time, the session is created with the machine login user account.
Finally tried this today and it worked :(just passed robot account name along with Machine name in Run job Activity.
@loginerror
this worked for a couple of days and now some other issue has come up.
we have 1-1 account-machine mapping in our folders due to the restrictions on no. of users that can login to the Machine/VM on our environment.
currently, we have 4 Machines added to the folder from where the robot is running.
even when i pass specific machine name and account combo in my run job activity, it is ignoring the account that i have specified and trying to run under some other account but on the same Machine.
for example :
machine and Account that are passed as arguments to Run Job : “VM1” and “UserAccount1”
but what’s happening during runtime is, its trying to invoke with “VM1” and “UserAccount2”
does seem to me like some bug. last 2 days, i configured only one Account-Machine in the folder but yesterday i have added 3 more, since then its randomly picking the Account to run with.. any idea why this could be?