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.
Answer
OData: Logging Into Acumatica OData using C#
Best answer by Dmitrii Naumov
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:
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.