curl --request POST \
--url http://localhost:4005/v1/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form 'description=Monthly financial report' \
--form outputFormat=html \
--form template='@example-file'import requests
url = "http://localhost:4005/v1/templates"
files = { "template": ("example-file", open("example-file", "rb")) }
payload = {
"description": "Monthly financial report",
"outputFormat": "html"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('description', 'Monthly financial report');
form.append('outputFormat', 'html');
form.append('template', 'monthly-report.tpl');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('http://localhost:4005/v1/templates', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "4005",
CURLOPT_URL => "http://localhost:4005/v1/templates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nMonthly financial report\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"outputFormat\"\r\n\r\nhtml\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\nmonthly-report.tpl\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:4005/v1/templates"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nMonthly financial report\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"outputFormat\"\r\n\r\nhtml\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\nmonthly-report.tpl\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:4005/v1/templates")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nMonthly financial report\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"outputFormat\"\r\n\r\nhtml\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\nmonthly-report.tpl\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4005/v1/templates")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nMonthly financial report\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"outputFormat\"\r\n\r\nhtml\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\nmonthly-report.tpl\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"createdAt": "2021-01-01T00:00:00Z",
"description": "Monthly financial report",
"fileName": "0196159b-4f26-7300-b3d9-f4f68a7c85f3_1744119295.tpl",
"id": "00000000-0000-0000-0000-000000000000",
"outputFormat": "HTML",
"updatedAt": "2021-01-01T00:00:00Z",
"warnings": [
{
"code": "DATA_SOURCE_UNAVAILABLE",
"field": "account.balance",
"message": "data source is temporarily unavailable"
}
]
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Subir una plantilla
Usa este endpoint para cargar una nueva plantilla en el sistema. Acepta un archivo .tpl que define la estructura y la lógica del informe.
El archivo debe tener el formato del tipo de salida deseado (HTML, XML, CSV, PDF o TXT) y utilizar los bloques del plugin Reporter cuando corresponda.
Independientemente del formato, el archivo siempre debe guardarse con la extensión .tpl para que la plantilla funcione correctamente.
curl --request POST \
--url http://localhost:4005/v1/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form 'description=Monthly financial report' \
--form outputFormat=html \
--form template='@example-file'import requests
url = "http://localhost:4005/v1/templates"
files = { "template": ("example-file", open("example-file", "rb")) }
payload = {
"description": "Monthly financial report",
"outputFormat": "html"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('description', 'Monthly financial report');
form.append('outputFormat', 'html');
form.append('template', 'monthly-report.tpl');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('http://localhost:4005/v1/templates', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "4005",
CURLOPT_URL => "http://localhost:4005/v1/templates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nMonthly financial report\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"outputFormat\"\r\n\r\nhtml\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\nmonthly-report.tpl\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:4005/v1/templates"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nMonthly financial report\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"outputFormat\"\r\n\r\nhtml\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\nmonthly-report.tpl\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:4005/v1/templates")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nMonthly financial report\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"outputFormat\"\r\n\r\nhtml\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\nmonthly-report.tpl\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4005/v1/templates")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nMonthly financial report\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"outputFormat\"\r\n\r\nhtml\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\nmonthly-report.tpl\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"createdAt": "2021-01-01T00:00:00Z",
"description": "Monthly financial report",
"fileName": "0196159b-4f26-7300-b3d9-f4f68a7c85f3_1744119295.tpl",
"id": "00000000-0000-0000-0000-000000000000",
"outputFormat": "HTML",
"updatedAt": "2021-01-01T00:00:00Z",
"warnings": [
{
"code": "DATA_SOURCE_UNAVAILABLE",
"field": "account.balance",
"message": "data source is temporarily unavailable"
}
]
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Autorizaciones
Autenticación mediante token Bearer. Formato: 'Bearer {access_token}'. Solo es obligatoria cuando el plugin de autenticación está habilitado.
Encabezados
Clave de idempotencia proporcionada por el cliente que evita la creación duplicada de plantillas.
Cuerpo
Formulario multipart de la plantilla.
Respuesta
Creado
Marca de tiempo que indica cuándo se creó la plantilla.
"2021-01-01T00:00:00Z"
Descripción breve de la plantilla. Opcional.
"Monthly financial report"
Nombre del archivo de plantilla tal como está guardado en el sistema. Sigue el formato <template_id>.tpl.
"0196159b-4f26-7300-b3d9-f4f68a7c85f3_1744119295.tpl"
ID único que identifica la plantilla (formato UUID).
"00000000-0000-0000-0000-000000000000"
Formato de salida generado (por ejemplo, HTML, CSV, PDF, TXT, XML).
"HTML"
Marca de tiempo que indica la última vez que se actualizó la plantilla.
"2021-01-01T00:00:00Z"
Se devuelve cuando la validación de esquema no pudo validar completamente una o más fuentes de datos referenciadas por la plantilla. La operación de creación o actualización se completa de todas formas. Ausente cuando no se produjeron advertencias.
Show child attributes
Show child attributes
[
{
"code": "DATA_SOURCE_UNAVAILABLE",
"field": "account.balance",
"message": "data source is temporarily unavailable"
}
]
¿Esta página le ayudó?

