Orchestrator API - bearer Token cancellation Error via UiPath Studio

Hi,
I have a problem colecting data from the Orchestrator database via API queries from UiPath Studio.
I created a mechanism for collecting parameters (counters) of status of cases in queues. I used the for each function to search through subsequent queues and collect data to the table.

The first authentication takes place without problems, data is collected and loaded into a row in the table.
At the second attempt, an error appears:
If I have used the Authentication sequence in the ‘for each’ activity, the error is on the second Authentication, I get the error:

RemoteException wrapping System.InvalidOperationException: Could not invoke client method.  ---> RemoteException wrapping System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Http.HttpClient'. 
   at System.Net.Http.HttpClient.CheckDisposed()
   at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request,
HttpCompletionOption completionOption,
CancellationToken cancellationToken)
   at UiPathWebApi.AccountClient.<AuthenticateAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at UiPath.WebClient.Activities.Generator.Swagger.BaseSwaggerActivity`3.<ExecuteAsync>d__50.MoveNext()
	--- End of inner exception stack trace ---
   at UiPath.WebClient.Activities.Generator.Swagger.BaseSwaggerActivity`3.<ExecuteAsync>d__50.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at UiPath.WebClient.Activities.Generator.Code.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context,
IAsyncResult result)
   at UiPath.WebClient.Activities.Generator.Code.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context,
IAsyncResult result)
   at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context,
IAsyncResult result)
   at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor,
BookmarkManager bookmarkManager)

In turn, if authentication pulls before activity ‘for each’ error, it appears when processing the second case in Get Queue Definitions.
The error message is similar in both cases, and it’s about canceling the Token.

Is the problem the validity of bearer Token?
The production environment has Orchestator 2018.4.4, and the documentation says that the default course is 30 minutes.

https://docs.uipath.com/orchestrator/v2018.4/reference#authenticating

What settings do I have on the Orchestrator, I do not know yet - this is in the process of determining, but please direct me if the cause of the problem lies in the bearer Token?

Hi @Adrian_Star

I am looking into it, it seems strange (or I don’t understand the issue completely just yet :sweat_smile:)

EDIT

Well, apparently it is a bug that was fully fixed in 2019.10.2 release. It was indeed caused by running library web service inside of a loop.

I believe there is a workaround posted here:

To call activities generated from web services multiple times inside a loop, create a separate workflow from the main library file, and invoke the service method there. In the main workflow, use the Invoke Workflow File activity inside a For Each activity, and invoke the previously created workflow.

And here is the note from the 2019.10.2 release notes that mentions it being fixed:

Fixed an issue that resulted in an exception when activities generated from web services in a library project were called multiple times inside a loop.

1 Like

@loginerror,
We upgraded the version:

  • UiPath Studio from version 2019.10.1 has been upgraded to version 2019.10.2.
    After running worflow in Debug mode - the problem is not resolved.

The problem was solved only after applying the following:

  • Converting the all GET sequence to workflow and using Invoke workflow in the for each loop helped.
1 Like

Thank you for an update. The only think I can suggest still to try is to republish the library project again and try then.

If this doesn’t fix it, we’ll look into it.

@loginerror,
In my case problem solved:

1 Like

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