Web Services: Retrieval of Reports Through the REST API
In previous versions of MYOB Acumatica, it was impossible to retrieve a report through the REST API. In MYOB Acumatica 2024.1, a developer can create a custom endpoint or extend an existing endpoint with an entity of the new Report type and use this entity to obtain the report from MYOB Acumatica.
Adding a Report Entity to an Endpoint
On the Web Service Endpoints (SM207060), the developer performs the following general steps to add a Report entity to an endpoint:
- Extends an existing endpoint or adds a new endpoint, as described in To Extend an Existing Endpoint or To Create a Custom Endpoint.
- In the endpoint, adds the entity of the Report type, as shown in the following screenshot.
- On the Fields tab, specifies the parameters that should be specified to run the report. By default, the tab is populated with the fields for each parameter of the report.
Requesting the Report
To obtain the report from MYOB Acumatica, the developer executes an HTTP request that satisfies the following requirements:
- HTTP method and URL: The developer sends the
POST
HTTP method to the following URL.POST http://<Endpoint URL>/<Report entity>
For example, suppose that the created endpoint has the http://localhost/AcumaticaDB/entity/Report/0001/ URL and the name of the report entity is CashAccountSummary. The developer would use the following HTTP method and URL.
POST http://localhost/AcumaticaDB/entity/Report/0001/CashAccountSummary
- Request headers: In the
Accept
header, the developer specifies the format in which the report should be returned. The format (and the respective header value) can be one of the following:- PDF:
application/pdf
- HTML:
text/html
- Excel:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Accept
header is not specified, the report is returned in PDF format. - PDF:
- Request body: In the request body, the developer specifies the parameters of the report
in JSON format, such as in the following example.
{ "CompanyBranch": {"value": "SOFT"}, "IncludeNonClearedTransactions": {"value": true} }
If no parameters are specified in the request body, the default parameters of the report are used.
The response of a successful request has the 202 Accepted status and includes the
Location
header, which specifies the URL that the developer should use to
obtain the requested report by using the GET
HTTP method. When the report
is ready, this GET
request returns the 200 OK status code. The
requested report is returned in the response body.