Skip to main content

Commands APIs

Lets you define REST API Services for your application.

First, create a Custom Command that will serve as a source of returned data.

If you want to return Entities, select Data grid report as result of the command. If you want to return files, select Document as a result.

Create attributes in the Command Model that will serve as parameters for your fetch requests.

Next, go back to REST API Services and click on Add service button:

General

  • API Type – Command or User authentication
  • Command to be invoked – Command which will be executed on a request to API. Only commands of type Custom command can be used in API.
  • Model mapping mode – You can choose from two modes:
    • JSON Deserialization – the request's body, formatted as JSON text, is deserialized into an object, and its properties are subsequently mapped to the command model's properties
    • Raw String Pass-through – the request's body is passed directly as a string to a specified attribute on the command model

API

  • Service name – Name of the API service
  • Service URL – Url on which the API will listen for incoming requests.
  • Authentication – Authentication schema for the API
  • Allowed technical users – A Technical user who will act as invoker of executed commands. Each technical user with assigned REST API Services will have their own API KEY in every application instance.

Examples

Command results

Every command returns an ICommandResult. The framework inspects the concrete type at the end of execution and serializes the HTTP response accordingly. This page covers all result types available to command authors, what they produce over the wire, and when to use each one.

DataResult

DataResult is a command result type for returning data payloads from Jetveo commands exposed via the REST Command API. When a command returns a DataResult, the framework serializes it directly into the HTTP response — no extra wiring needed.

DataResult.CommandJson — enveloped JSON (Jetveo command protocol)

Returns a JSON response wrapped in the standard Jetveo command envelope:

{ "success": true, "message": "...", "result": { ... } }
DataResult.CommandJson(object data, bool success = true, string message = "", JsonSerializerOptions serializationOptions = null)

HTTP status code follows the success flag: 200 OK for true, 400 Bad Request for false. Serialized with System.Text.Json.

DataResult.Json — plain JSON

Returns the data serialized as JSON with no envelope. Two overloads:

// Serialize a CLR object with System.Text.Json
DataResult.Json(object data, JsonSerializerOptions serializationOptions = null)

// Pass a pre-serialized JSON string through as-is (no re-serialization)
DataResult.Json(string json)

Use Json(object) when you have a CLR object and want a clean JSON response without the command envelope. Use Json(string) when you have already-serialized JSON — for example, when proxying a response from an external service.

return DataResult.Json(new { items = list, total = list.Count });

return DataResult.Json(rawJsonFromExternalApi);

DataResult.Xml — XML

Serializes the object using System.Xml.Serialization.XmlSerializer. Content-Type is application/xml; charset=UTF-8.

DataResult.Xml(object data, XmlWriterSettings settings = null)
return DataResult.Xml(myDto);

return DataResult.Xml(myDto, new XmlWriterSettings { Indent = true });

DataResult.Text — plain text or other text formats

Returns a string response with a configurable MIME type. Defaults to text/plain.

DataResult.Text(string content, string mimeType = "text/plain")
return DataResult.Text("Hello, world!");

return DataResult.Text("<h1>Hello</h1>", mimeType: "text/html");

return DataResult.Text(csvContent, mimeType: "text/csv");

DataResult.Data — raw binary

Returns raw bytes with a configurable MIME type. Providing a fileName adds a Content-Disposition: attachment header, which triggers a file download in browsers.

DataResult.Data(byte[] data, string mimeType, string fileName = null)
return DataResult.Data(pdfBytes, mimeType: "application/pdf", fileName: "report.pdf");

return DataResult.Data(imageBytes, mimeType: "image/png");

Appendix: Polymorphism

System.Text.Json serializes the declared type and will silently omits any properties defined derived properties. For more details, see the official System.Text.Json documentation .

CommandResult — success or failure

The base type. Use it when the command has no data to return beyond whether it succeeded.

return new CommandResult(true, "Order submitted successfully.");
return new CommandResult(false, "Insufficient stock.");

HTTP response:

{
"success": true,
"message": "Order submitted successfully."
}

ReportResult — tabular data

Returns a table of rows and columns returned by REST API callers as an array of objects.

Columns and rows are merged into an array of objects keyed by column label:

var columns = new[]
{
new ReportResult.Column("Product", ReportResult.ColumnType.Text),
new ReportResult.Column("Quantity", ReportResult.ColumnType.Number),
};
var rows = items.Select(i => new ReportResult.Row(i.Product, i.Quantity));
return new ReportResult(columns, rows, message: "Stock levels");

HTTP response

{
"success": true,
"message": "Stock levels",
"report": [
{
"Product": "Widget A",
"Quantity": 42
},
{
"Product": "Widget B",
"Quantity": 7
}
]
}

DocumentResult — file download

Returns a document to API callers.

return new DocumentResult("export.xlsx", excelBytes);

HTTP response:

{
"success": true,
"message": "",
"documentId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"filename": "export.xlsx",
"content": "UEsDBBQABg..."
}

RedirectResult — navigation

The REST API callers receive the url field and can perform the navigation themselves.

return new RedirectResult("https://example.com/confirmation", RedirectResult.Target.NewTab);

HTTP response:

{
"success": true,
"message": "",
"url": "https://example.com/confirmation"
}