acumatica Exporting Records via REST Contract-Based API

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


This topic will demonstrate how to export records from Acumatica ERP via the REST Contract-Based API. In contrast to the Screen-Based API of Acumatica ERP, the Contract-Based API provides both SOAP and REST interfaces. For more information on the Contract-Based API, see Acumatica ERP Documentation


To communicate with the REST Contract-Based API of Acumatica ERP your client application must always perform the following 3 steps:

  1. log into Acumatica ERP instance and get cookie with user session information

  2. interact with one of Contract-Based API endpoints available on Acumatica ERP instance

  3. log out from Acumatica ERP to close user session

All samples provided in this topic were built with the Default endpoint, always deployed as part of the standard Acumatica ERP installation process. On the Web Service Endpoints screen (SM.20.70.60) you can view the details of existing endpoints or configure your custom endpoints of the Acumatica ERP contract-based web services:

enter image description here

For your reference, below is implementation of the RestService class used in all samples above to interact with the Contract-Based web service of Acumatica ERP:

public class RestService : IDisposable
    private readonly HttpClient _httpClient;
    private readonly string _acumaticaBaseUrl;
    private readonly string _acumaticaEndpointUrl;

    public RestService(string acumaticaBaseUrl, string endpoint,
        string userName, string password,
        string company, string branch)
        _acumaticaBaseUrl = acumaticaBaseUrl;
        _acumaticaEndpointUrl = _acumaticaBaseUrl + "/entity/" + endpoint + "/";
        _httpClient = new HttpClient(
            new HttpClientHandler
                UseCookies = true,
                CookieContainer = new CookieContainer()
            BaseAddress = new Uri(_acumaticaEndpointUrl),
            DefaultRequestHeaders =
                Accept = {MediaTypeWithQualityHeaderValue.Parse("text/json")}

        var str = new StringContent(
            new JavaScriptSerializer()
                        name = userName,
                        password = password,
                        company = company,
                        branch = branch
                    Encoding.UTF8, "application/json");

        _httpClient.PostAsync(acumaticaBaseUrl + "/entity/auth/login", str)

    void IDisposable.Dispose()
        _httpClient.PostAsync(_acumaticaBaseUrl + "/entity/auth/logout",
            new ByteArrayContent(new byte[0])).Wait();

    public string GetList(string entityName)
        var res = _httpClient.GetAsync(_acumaticaEndpointUrl + entityName)

        return res.Content.ReadAsStringAsync().Result;

    public string GetList(string entityName, string parameters)
        var res = _httpClient.GetAsync(_acumaticaEndpointUrl + entityName + "?" + parameters)

        return res.Content.ReadAsStringAsync().Result;

Got any acumatica Question?