This section provides an overview of what acumatica is, and why a developer might want to use it.
It should also mention any large subjects within acumatica, and link out to the related topics. Since the Documentation for acumatica is new, you may need to create initial versions of those related topics.
This example is applicable to Acumatica 6.0 series
All sample provided in this topic were created with the Screen-Based API Wrapper. If you want your client application to not depend on the UI changes in the Acumatica ERP application, you should use the screen-based API wrapper, which is described in Acumatica ERP Documentation
To communicate with the REST Contract-Based API of Acumatica ERP your client application must always perform the following 3 steps:
log into Acumatica ERP instance and get cookie with user session information
interact with one of Contract-Based API endpoints available on Acumatica ERP instance
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:
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()
.Serialize(
new
{
name = userName,
password = password,
company = company,
branch = branch
}),
Encoding.UTF8, "application/json");
_httpClient.PostAsync(acumaticaBaseUrl + "/entity/auth/login", str)
.Result.EnsureSuccessStatusCode();
}
void IDisposable.Dispose()
{
_httpClient.PostAsync(_acumaticaBaseUrl + "/entity/auth/logout",
new ByteArrayContent(new byte[0])).Wait();
_httpClient.Dispose();
}
public string GetList(string entityName)
{
var res = _httpClient.GetAsync(_acumaticaEndpointUrl + entityName)
.Result.EnsureSuccessStatusCode();
return res.Content.ReadAsStringAsync().Result;
}
public string GetList(string entityName, string parameters)
{
var res = _httpClient.GetAsync(_acumaticaEndpointUrl + entityName + "?" + parameters)
.Result.EnsureSuccessStatusCode();
return res.Content.ReadAsStringAsync().Result;
}
}
In all samples above, you made changes to both the _AllowedValues
and _AllowedLabels
arrays. If your task is to modify only label (external value) of a drop-down item, consider using Translation Dictionaries. For more information on Translation Dictionaries see
Acumatica ERP Documentation
The code snippet above was created using the Json.NET framework (Newtonsoft.Json.dll).
To obtain HTTP cookie header from a SOAP response, add a reference to the .Net framework System.ServiceModel and System.ServiceModel.Web assemblies and the following 2 using directives in your code file:
using System.ServiceModel;
using System.ServiceModel.Web;