Access data service from coded workflow

I am trying to build a coded workflow that retrieves data from Data Service, however I don’t seem to be able to quite understand how.

I am able to import UiPath.DataService
I can create an instance of my entity on the coded workflow

but
I can’t import DataService.Client nor DataService.Definition

is that even possible from a coded workflow? implementation insights are very welcome.

C# is not my native language, so any Ideas of advanced concepts I need to research are also welcome.

I initially thought on an implementation like this but the compiler says there is no implicit conversion from my entity type to DataService.Definition.IEntity
however the compiler also doesn’t accept if I try to invoke using DataService.Definition


var orders = new 
UiPath.DataService.Activities.QueryEntityRecords<MyEntity>()
.Where(e=> e.OrderId == InputValue).ToList();

A working snipped would be fabulous, you will get my eternal thanks!

Also please note:
I don’t mean disrespect by any means, but I am not looking for alternatives nor low-code workarounds since I am not trying to resolve an automation use case, instead I am trying to create a customized library based on our specific infrastructure requirements.

Hi @Botzilla

Check the below thread

Hope it helps!!

1 Like

yeah, that was my 1st reference. I am actually trying to implement something like what @arivu96 suggested on the same topic, I created this post since that one is already closed and can’t reply there anymore. However, I am unsure if I am using a different specification of the SDK. Anyways, appreciate your interest to help. :robot:

2 Likes

Hi @Botzilla

In coded, it does not allow direct use of DataService.Client or IEntity types because they are made for visual activities. That’s why you get errors when trying to use them.

If you still want to get data from Data Service in code, you can call the Data Service API using HTTP Request. First, get an access token using OAuth, then use the token to call the API and get data in JSON. After that, convert the JSON to objects or DataTable for use in your workflow.

This way works even in libraries or advanced setups when direct activity use is not supported.

1 Like

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