Skip to main content
Answer

Odata Client using C#

  • March 2, 2024
  • 6 replies
  • 404 views

jcavanagh
Freshman I
Forum|alt.badge.img

Thank you Tim Rodman for the feedback on using Odata to access. I found the excel exports would produce errors in python pandas. 

I am exploring options, and found that C# has much better Odata support than Python, due to Odata being under the MS Umbrella, so it seems likely that I will go ahead with using C# 

This template looked to be very helpful in creating a Odata Consumer and I look to adapt this into a Odata Consumer that I can use as the first Extract step of an ETL pipeline. 

AspNetOdata/ConsoleConsumer at master · stevsharp/AspNetOdata (github.com)

 

Am I reinventing the wheel here? Has anyone else used C# to get data out of Acumatica?

Best answer by Dmitrii Naumov

Hey @jcavanagh 

We have an OData client for C# here:

https://github.com/Acumatica/AcumaticaRESTAPIClientForCSharp/tree/master/Acumatica.RESTClient.OData

However, I’m not sure if it satisfies the requirements you may have. What are the specific things you’d like to do with that? I’d assume Linq support?

6 replies

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • Answer
  • March 4, 2024

Hey @jcavanagh 

We have an OData client for C# here:

https://github.com/Acumatica/AcumaticaRESTAPIClientForCSharp/tree/master/Acumatica.RESTClient.OData

However, I’m not sure if it satisfies the requirements you may have. What are the specific things you’d like to do with that? I’d assume Linq support?


@Dmitrii Naumov Old thread, but since you brought up the OData code you have up on Github I had a quick question. When I try to pull data using this library it only pulls 1 record at a time. Is there something special I have to do so it doesn’t just pull the first record?

I use your example like this and I would have expected to see 5 results, not 1. And yes, the GI has more than 5 records when you load it on the website.

var giResult = client.GetOData(ODataVersion.GIBasedOData, giName, tenant: tenant, top: 5);

 

Thanks for any help!


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • May 22, 2025

@mmarklow44 OData client does not deserialize things automatically. I assume you are getting back 1 JsonObject? Check inside, the results should be there.


@Dmitrii Naumov I’m basically doing the same thing the ODataExample.cs is doing in the Acumatica REST API Example Console Application. Is this sample code not correct? I didn’t test this code specifically, but the only real change was to use a different GI Name in that giName variable. So I guess that is possible it’s not doing what I expect it to do.
 

                var objects = client.GetOdataObjects(ODataVersion.GIBasedOData, tenant);

var giName = "BI-ARInvoices";
if (objects.Where(gi => gi.Name == giName).Any())
{
Console.WriteLine("Retrieving 5 AR Invoices with GI-based OData");
var giResult = client.GetOData(ODataVersion.GIBasedOData, giName, tenant: tenant, top: 5);
Console.WriteLine($"Retrieved {giResult.Count()} Invoices");
}
else
{
Console.WriteLine($"Generic Inquiry {giName} not found");
}

 


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • May 22, 2025

@mmarklow44 what is the client version that you use?

What is the type of giResult that you get there? 


@Dmitrii Naumov Well, now I feel silly. I just tried again and rather than get a count of 1 I now get a count of 5 when pulling the top 5 and the full amount (11) when not passing a number. Maybe I was doing something wrong before and I didn’t notice. I deleted the code I was testing so I’m not sure. I apologize for wasting your time! But thank you very much for taking the time out of your day to respond.

 - Mitch