Passing a DataTable to an Agent from Studio Web

Hi -

Please help!!!

I am trying to pass a data table from StudioWeb into an Agent. The DataTable in studio web has more columns that what I am passing into the Agent. How do I only pass the columns I want (guidance on the expression would be great), or do I have to create a new DataTable with ONLY the columns I want?


List of Columns in my DataTable: ControlNumber1,ControlName,BankAccountNumber,StatementNumber,StatementLineNumber,TransactionDate,UserReference,Amount,Allocated,DebtorName,RMAReference,PaymentReference,BankTransactionCode

Thoughts?

PS - it works well if I call it as I iterate through the table, but the problem is it then takes too long and times out when I am testing it.
Below the expresion when iterating through, I just can’t figure it out to do as a full data table:

Expression for 1 column: CurrentRow(“Amount”).ToString()

@Ryan_Beangstrom

Ideally rather than passing datatable it would be good if you take input as json array ..and datatable can be serialized as a json array and can be passed it is more freindly

A reference for converting to jarray here

Apart from that if tou want to pass datatable only with required columns then you can just filter datatable and pass columns you want..but agent can handle a jarray better I feel

Cheers

1 Like

@Anil_G - thanks for the input.

I am still struggling. I have done the following,

Created a variable ArrayofObject. Converted my DataTable to objectArray by:

FilteredTable.AsEnumerable().Select(Function(row) FilteredTable.Columns.Cast(Of DataColumn).ToDictionary(Function(col) col.ColumnName, Function(col) row(col))).ToArray()

I then try pass this to my Agent like this:
JsonConvert.SerializeObject(CType(ArrayofObject, List(Of Dictionary(Of String, Object))))

But still get this error message:
2025-07-24 15:00:03.763 GMT+5: Error: System.InvalidCastException: Unable to cast object of type ‘System.Collections.Generic.Dictionary2[System.String,System.Object][]' to type 'System.Collections.Generic.List1[System.Collections.Generic.Dictionary`2[System.String,System.Object]]’.
at Namespace_d0a7.Main_Expressions.Main_Expressions_TypedDataContext2_ForReadOnly.__Expr25Get()
at Namespace_d0a7.Main_Expressions.Main_Expressions_TypedDataContext2_ForReadOnly.ValueType___Expr25Get()
at Namespace_d0a7.Main_Expressions.InvokeExpression(Int32 expressionId, IList`1 locations, ActivityContext activityContext)
at Microsoft.VisualBasic.Activities.VisualBasicValue`1.Execute(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity`1 expressionActivity)
at System.Activities.InArgument`1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate)
at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Any chance we could hop on a call to solve this together?

Thanks!

@Ryan_Beangstrom

Hi,

Assign String variable as below as use same expression to convert String to Json:
JsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(Datatable_Name)

Now pass JsonStr to Agent.

Hope this helps!

@Ryan_Beangstrom

as per error you are casting an array to list thats why the error instead use ArrayOfObject.ToList and try

cheers

Still not working, I have changed to passing the JSON as a string. I have the following:

In my log I have the correct JSON string:
image

But when I parse it to my agent I get the following message:
and it seems it is looking for a file and not a string. Here is an image of myparse:

Any ideas???

2025-07-24 16:33:04.273 GMT+5: Error: System.Exception: InputFile does not exist. Error code: 5800
at UiPath.Activities.System.Jobs.RunJob.JobFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

@Ryan_Beangstrom

what is the input variable type needed for your agent?

I believe there you would have given a file

cheers

**Please check the variable types. **
Also, check on which activity you are getting error.

Note: make sure to mention in the prompt that you are passing the JSON as a string.
Update other prompts accordingly to reflect this as well.

Make these adjustments throughout to avoid any type mismatch or unexpected behavior.

Anyone want to hop on a call and help me debug? Ill pay in beer?

A string… Pretty straightforward

The agent works well when I test it on its own with a JSON string, problem is calling it from my workflow. Somehow thinks the string is a file location and I dont know how to change that

1 Like

Try calling the agent from another smaller flow.
Hopefully, it should work in this case.

Could you find any solutions for this error:

Error: System.Exception: InputFile does not exist. Error code: 5800
at UiPath.Activities.System.Jobs.RunJob.JobFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)