Skip to main content
Answer

OData: Logging Into Acumatica OData using C#

  • September 10, 2025
  • 7 replies
  • 139 views

zherring
Freshman I

I am currently writing a small C# console app in Visual Studio to pull GI records from a GI that is exposed through OData. I have been searching through documentation and cannot seem to figure out what I need to actually login to Acumatica in order to access the OData.

Right now I can use the URL of <Acumatica ERP instance URL>/t/<TenantName>/api/odata/gi but I get a 401 error for not being signed in. I tried creating a JSON payload to login using <Acumatica ERP instance URL>/entity/auth/login but I keep getting a 500 error for invalid credentials. I am unsure if my URL is wrong, or I do not have the right things in my payload, or maybe I am trying to set up the HTTP Client all wrong. Does anyone have knowledge in this area or a link to a complete/updated guide?

My ultimate goal is to find records from this GI based on a certain condition, and then use the REST API to generate the report for each record and save it a separate folder.

Best answer by Dmitrii Naumov

@zherring 

You can use either OAuth 2.0 or Basic Auth for Odata.

For OAuth 2.0 see here:

https://help.acumatica.com/(W(6))/Help?ScreenId=ShowWiki&pageid=a8f71c44-9f5c-4af8-9d47-bc815c8a58e7

 

For the basic Auth you can see here:

https://openuni.acumatica.com/courses/integration/i300-web-services-data-retrieval-with-odata/

 

By the way, we have a C# API client on github:

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

Examples of usage: 

https://github.com/Acumatica/AcumaticaRESTAPIClientForCSharp/blob/5.0/Acumatica%20REST%20API%20Console%20Application/ODataExample.cs

7 replies

Forum|alt.badge.img+7
  • Captain II
  • September 10, 2025

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • Answer
  • September 10, 2025

zherring
Freshman I
  • Author
  • Freshman I
  • September 11, 2025

@Dmitrii Naumov 
EDIT:
I now have access...I was missing one pesky letter from my username…

I am currently trying to leverage the repo you linked from github. Right now I am trying to run the OData example code but with my siteURL, username, password, etc. but I keep getting an error 401 for not being authorized.

I did set up the “Connected Applications” in Acumatica to get my ClientSecretROPC and ClientIDROPC. 

Is there an easy way to see why the authorization is failing?


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • September 11, 2025

@zherring could you share an example of the code that you are trying?


zherring
Freshman I
  • Author
  • Freshman I
  • September 11, 2025

@Dmitrii Naumov 

I ended up having a pesky typo in my username...I now have successfully pulled OData!

This github repo saved me a lot of headaches!


zherring
Freshman I
  • Author
  • Freshman I
  • September 11, 2025

@Dmitrii Naumov 

I got stuck on another part. I was able to get the OData successfully using OAuth2.0 but then I try to leverage the REST API to enter a type/refNbr into Invoice/Memo - AR641000 to get a pdf back.

I am using:

var response = await client.CallApiAsync(
resourcePath: endpointPath,                 
method: HttpMethod.Post,
acceptType: HeaderContentType.Any,
contentType: HeaderContentType.Json,
body: body,
customHeaders: headers,
cancellationToken: ct
).ConfigureAwait(false);

I keep getting an 406 error code. According to the dump from the ‘swagger’ method, I should be getting back a code of 202 and a location URL and then I believe I have to do a GET once the report is done. So I am thinking that I am using the parameters wrong for CallApiAsync/


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • September 15, 2025

@zherring the issue is that you cannot send acceptType = Any

 

I’ve updated the github repo to support the Reports API

https://github.com/Acumatica/AcumaticaRESTAPIClientForCSharp/blob/5.0/Acumatica.RESTClient.ContractBasedApi/ApiClientExtensions.cs#L252