Loading ...

Localized reports in Acumatica

One of the recent additions to the new Acumatica 24R1 version is the ability to retrieve localized reports through REST API. This article provides a manual how specifically one can achieve it.

 

We start of creating an endpoint for reports. For this we navigate to the Web Service Endpoints (SM207060) screen. In this article we will create a new endpoint, but it also works with extended endpoints.

To create an endpoint click a “+” sign at the top toolbar. On the screen that opens, we specify the endpoint name and endpoint version and save the changes.

 

Now we need to create an entity. We can achieve it by clicking “Insert” button on the endpoint view at the left side of the screen

A pop-up window shows up, where we specify the name of an entity and the screen id, which it is going to be originated from. For this example, we will create an API endpoint for retrieving Invoice/Memo (SO643000) reports in pdf. Thus we populate the fields with the following values:

Click “OK”. Now, as we created the entity, we can manipulate parameters that are going to be specified in the HTTP request later, by selecting the “Fields” tab, if we need that. For this example the default settings are good enough, so we will leave them as they are.

Now let’s head in to Postman and test our endpoint.

 

First, we have to log into Acumatica. For this we send a POST request to this address:

{{baseUrl}}/entity/auth/login

Where baseUrl is the url to an Acumatica instance. In my case it is http://localhost/demo

In request body we specify username and password as follows:

An expected response is 204 No Content

 

Now we need to retrieve a link to a report. To do this, we send a POST request to this url:

 

{{baseUrl}}/entity/{{endpointName}}/{{endpointVersion}}/

{{entityName}}

 

Where {{endpointName}} is the name of an endpoint (in our case “Report”), {{endpointVersion}} is the version we specified for this endpoint (in our case 23.200.001), and {{entityName}} is the name of an entity we are trying to retrieve (in our case InvoiceMemo)

In headers we need to specify the following keys:

And then in the request body we specify the parameters values that we have set up at the “Fields” tab at the Web Service Endpoint screen.

We send a report and expected response is 202 Accepted. However, what we need in the response is the value of the Location header

This link specifies where we can retrieve our actual PDF report from. For this we copy the value and send a GET request to this address:

 

{{host}}/{{Location}}

 

Where {{host}} is the host of an Acumatica instance. In response we get our report .

Now let’s modify this request to retrieve a localized report.

 

For this we first have to navigate to the System Locales (SM200550) screen, create a new locale and check the “Active” checkbox.

Then we navigate to the Translation Dictionaries (SM200540) screen, search for a field and set a translation to it. Let’s take the “Unit Price” fiend and translate it and save the changes.

Now, going back to our Postman requests. In the request to get a report location, we specify yet another header called Accept-Language and assign it the value of the locale name as follows.

After that we repeat the same steps, copy the location and send a GET request to get an actual PDF report and in the end report generates with the translation we added.