This is an example on how to call Ambience/Repertoire 202x API to output a RML template using curl.
Rendering RML Template w/ Parameters
API Structure:
[protocol]:[host]:[port]/rml-engine/render?elx-token=[token-value]
Create API Token
Add an API token and assign a user account to this API token. The API token string will be appended to the API call in a later step.
Create Role
Add a role and assign a user that has the following access privileges, mod-ds-engine & mod-rml-engine
Sample Report Template
For this example we will use a sample report template with a parameter. The path of this report is:
For example, “/QA_Samples/RML/Parameters/Password_Parameter.rml”Creating a HTTP call
Using the HTTP endpoint, construct the HTTP call to the rml rendering engine by appending ‘?elx.token=’ & the API token.
For example,
“http://localhost:1740/rml-engine/api/v1/render?elx.token=6175c322-e5bf-425c-b10d-78d886092e52”
Construct a header in JSON format.
For example,
-H “Content-Type: application/json” -d “{"rml":
"/QA_Samples/RML/Parameters/Password_Parameter.rml","Password":
"testparameter","renderDetails": { "RenderAsImage": "Yes", "AllowScreenReaders": "No" }}” -o result.pdfTest the API call using curl
For example,
curl -v -X POST http://localhost:1740/rml-engine/render?elx.token=6175c322-e5bf-425c-b10d-78d886092e52 -H “Content-Type: application/json” -d “{\“rml\”:\”/ElixirSamples/Report/RML/Map.rml\“,\“renderDetails\”: { \“RenderAsImage\”: \“Yes\”, \“AllowScreenReaders\”: \“No\”}}” -o result.pdf
Notes:
- Another way would be to write the report template, its rendering options and parameters to a JSON file and specify the path of the JSON file.
- For more details, do take a look at this documentation:
Rendering a report template via REST API.pdf (287.6 KB)
Rendering RML Template using Tabular Datasource
API Structure:
[protocol]:[host]:[port]/rml-engine/render?elx-token=[token-value]
Create API Token
Add an API token and assign a user account to this API token. The API token string will be appended to the API call in a later step.
Create Role
Add a role and assign a user that has the following access privileges, mod-ds-engine & mod-rml-engine
Upload the Tabular Datasource up on the Repository module.
(i.e. FruitSales)In your local system, edit the RML template using an editor of your choice.
(i.e. Notepad++)Go to ‘rml:datasource’ tag & edit the ‘datasource-name’ path to the datasource path over in Ambience 2021.
For example,
Save the RML template & upload it up to Ambience 2021 Repository Module.
Creating a HTTP call
Using the HTTP endpoint, construct the HTTP call to the rml rendering engine by appending ‘?elx.token=’ & the API token.
For example,
“http://localhost:1740/rml-engine/render?elx.token=6175c322-e5bf-425c-b10d-78d886092e52”
Test the API call using CURL
For example,
curl -v -X POST http://localhost:1740/rml-engine/render?elx.token=6175c322-e5bf-425c-b10d-78d886092e52 -d ‘{“rml”:“[path-to-report]”}’ -o result.pdf
Reference: Report and Datasource Engine Modules · Repository