### Install Keycloak Docker Image Source: https://github.com/bxservice/idempiere-rest/blob/master/com.trekglobal.idempiere.rest.api/keycloak/Testing Steps.txt Run this command to start a Keycloak instance in development mode, accessible on port 9080 with admin credentials. ```bash sudo docker run -p 9080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:21.1.1 start-dev ``` -------------------------------- ### Example GET Request for Single Record Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/02-models.md Demonstrates a GET request to retrieve a specific invoice record, expanding its lines and selecting document number and amount. ```http GET /v1/models/C_Invoice/12345?$expand=Lines&$select=DocumentNo,Amount ``` -------------------------------- ### Example GET Request for Single Property Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/02-models.md Illustrates a GET request to fetch the 'Amount' property of a specific invoice record. ```http GET /v1/models/C_Invoice/12345/Amount ``` -------------------------------- ### Process JSON Example Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/10-types.md Example JSON for the Process class, representing iDempiere process or report metadata. ```json { "processID": 101, "name": "Generate Invoice", "value": "GenerateInvoice", "description": "Creates invoices from orders", "isReport": false, "parameters": [ { "name": "Order", "columnName": "C_Order_ID", "displayType": 19, "mandatory": true } ] } ``` -------------------------------- ### LoginParameters Example JSON Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/10-types.md An example JSON payload for specifying login context parameters, such as role, client, organization, warehouse, and language. ```json { "roleId": "102", "clientId": "11", "organizationId": "*", "warehouseId": "103", "language": "en_US" } ``` -------------------------------- ### Example GET Request for Multiple Records Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/02-models.md Shows a GET request to retrieve invoice records, filtered by status, ordered by document number, and paginated. ```http GET /v1/models/C_Invoice?$filter=DocStatus eq 'CO'&$orderby=DocumentNo&$top=10&$skip=0 ``` -------------------------------- ### Webhook Payload Template Format Example Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/08-webhooks.md An example demonstrating the template format, which supports variable substitution using column names and related fields. ```plaintext Invoice ${DocumentNo} for ${BPartner_ID.Name} amount ${Amount} ``` -------------------------------- ### LoginCredential Example JSON Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/10-types.md An example JSON payload for authenticating a user, including username, password, and optional login parameters. ```json { "userName": "admin", "password": "password123", "parameters": { "roleId": "102", "clientId": "11", "organizationId": "101", "warehouseId": "103", "language": "en_US" } } ``` -------------------------------- ### Webhook IP Allowlist Example Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/11-configuration.md This example shows a comma-separated list of IP addresses and CIDR blocks that are permitted to send webhooks to the iDempiere REST API. ```text 192.168.1.0/24,10.0.0.0/8,127.0.0.1 ``` -------------------------------- ### Create and Populate LoginClaims for JWT Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/06-jwt-tokens.md Example of creating a LoginClaims object, setting its fields, and preparing it for JWT token creation. ```java LoginClaims claims = new LoginClaims(); claims.setSubject("admin"); claims.setName("Administrator"); claims.setClientId(11); claims.setRoleId(102); claims.setOrganizationId(101); claims.setLanguage("en_US"); claims.setRoles(Arrays.asList("ROLE_ADMIN", "ROLE_USER")); // Use in JWT token creation ``` -------------------------------- ### Insert REST API Configuration Values Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/11-configuration.md Example SQL script to insert initial configuration values into the ad_sysconfig table. ```sql INSERT INTO ad_sysconfig (ad_sysconfig_id, ad_client_id, ad_org_id, name, value, description, isactive, created, createdby, updated, updatedby) VALUES (1001, 0, 0, 'REST_API_ENABLED', 'Y', 'Enable REST API', 'Y', now(), 100, now(), 100), (1002, 0, 0, 'REST_TOKEN_EXPIRE_IN_MINUTES', '60', 'Token lifetime', 'Y', now(), 100, now(), 100), (1003, 0, 0, 'REST_QUERY_DEFAULT_TOP', '20', 'Default page size', 'Y', now(), 100, now(), 100), (1004, 0, 0, 'REST_REQUIRE_HTTPS', 'N', 'HTTPS requirement', 'Y', now(), 100, now(), 100), (1005, 0, 0, 'REST_OIDC_ENABLED', 'N', 'OIDC authentication', 'Y', now(), 100, now(), 100); ``` -------------------------------- ### Execute Basic Process Request Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/04-processes.md Example of executing a basic process. This demonstrates the required POST request format and a simple JSON payload for process parameters. ```http POST /v1/processes/GenerateInvoice Content-Type: application/json { "C_Order_ID": 12345, "CreateShipment": "Y" } ``` -------------------------------- ### Authenticate User with KeycloakProvider Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/09-oidc.md Example of obtaining an IOIDCProvider service and authenticating a user if the provider is a KeycloakProvider. ```java IOIDCProvider provider = Service.locator() .locate(IOIDCProvider.class) .getService(); if (provider instanceof KeycloakProvider) { AuthenticatedUser user = provider.authenticate(authCode, state); } ``` -------------------------------- ### Python Client for iDempiere REST API Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/00-index.md Example of a Python client using the 'requests' library to authenticate and fetch invoice data. It demonstrates how to handle authentication and make GET requests. ```python import requests import json BASE_URL = "http://localhost:8080/rest/v1" USERNAME = "admin" PASSWORD = "adempiere" # Authenticate auth_response = requests.post( f"{BASE_URL}/auth/tokens", json={"userName": USERNAME, "password": PASSWORD} ) token = auth_response.json()["token"] # Make request headers = {"Authorization": f"Bearer {token}"} invoices = requests.get( f"{BASE_URL}/models/C_Invoice", headers=headers, params={"$top": 10} ) print(json.dumps(invoices.json(), indent=2)) ``` -------------------------------- ### GET /v1/windows Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/03-windows.md Lists all available windows in the iDempiere system. Supports filtering, expanding details, and selecting specific columns. ```APIDOC ## GET /v1/windows ### Description List available windows. ### Method GET ### Endpoint /v1/windows ### Query Parameters - **$filter** (String) - Filter expression on window names/values - **$expand** (String) - Include additional details - **$select** (String) - Specific columns to return ### Response #### Success Response (200 OK) - **id** (integer) - Unique identifier for the window - **name** (string) - Name of the window - **slug** (string) - URL-friendly identifier for the window - **tableName** (string) - The database table associated with the window ### Response Example ```json [ { "id": 143, "name": "Invoice", "slug": "invoice", "tableName": "C_Invoice" } ] ``` ``` -------------------------------- ### Java Usage Example for Webhook Payload Template Resolver Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/08-webhooks.md Resolve a template string by providing the template and a PO object. This example shows how to dynamically generate a description for an invoice. ```java String template = "Invoice ${DocumentNo} for ${C_BPartner.Name}"; PO invoice = new MInvoice(ctx, invoiceID, null); String resolved = WebhookPayloadTemplateResolver.resolveTemplate(template, invoice); // Result: "Invoice INV001 for Acme Corp" ``` -------------------------------- ### FileInfo JSON Example Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/10-types.md Represents file metadata returned from process outputs. Includes filename, size, creation timestamp, path, and content type. ```json { "name": "invoice_report.pdf", "size": 102400, "created": "2024-01-15T10:30:00Z", "path": "/reports/550e8400-e29b-41d4-a716-446655440000/invoice_report.pdf", "contentType": "application/pdf" } ``` -------------------------------- ### GET /v1/auth/language Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/01-authentication.md Get default client language. ```APIDOC ## GET /v1/auth/language ### Description Get default client language. ### Method GET ### Endpoint /v1/auth/language ### Parameters #### Query Parameters - **client** (int) - Yes - Client ID ### Response #### Success Response (200 OK) - **language** (string) - Default language code ### Response Example ```json { "language": "en_US" } ``` ``` -------------------------------- ### Webhook Request Headers Example Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/08-webhooks.md This example shows the standard HTTP headers included in an outbound webhook request. Verify the signature using the shared secret and timestamp. ```http POST /webhooks/invoice HTTP/1.1 Content-Type: application/json X-Webhook-ID: 550e8400-e29b-41d4-a716-446655440000 X-Webhook-Signature: sha256=abcdef... X-Webhook-Timestamp: 2024-01-15T10:30:00Z X-Webhook-Event: invoice.created User-Agent: iDempiere-Webhook/1.0 ``` -------------------------------- ### Query Data with OData Parameters Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/README.md This example demonstrates how to query specific data using OData parameters like filtering ('$filter'), ordering ('$orderby'), and limiting results ('$top'). ```bash curl -X GET "http://localhost:8080/rest/v1/models/C_Invoice?\ $filter=DocStatus%20eq%20%27CO%27&\ $orderby=!DocumentNo&\ $top=20" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Verify REST API Installation Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/00-index.md Check if the REST API is running and accessible by making a health check request. ```bash curl http://localhost:8080/rest/v1/health ``` -------------------------------- ### Get Process Details Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/04-processes.md Fetches detailed information about a specific process, including its parameters. Requires the process slug as a path parameter. ```java Response getProcess(@PathParam("processSlug") String processSlug) ``` -------------------------------- ### Inbound Webhook Response Example Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/08-webhooks.md Example JSON response received after successfully submitting an inbound webhook event. Indicates the event was accepted for processing. ```json { "id": "webhook_event_123", "status": "Received", "message": "Webhook event accepted for processing" } ``` -------------------------------- ### GET /v1/processes/{processSlug} Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/04-processes.md Retrieves detailed information about a specific process, including its parameters. ```APIDOC ## GET /v1/processes/{processSlug} ### Description Retrieves details and parameters for a specific process identified by its slug. ### Method GET ### Endpoint /v1/processes/{processSlug} ### Parameters #### Path Parameters - **processSlug** (String) - Required - Process identifier (slug of process value) ### Response #### Success Response (200 OK) - **id** (integer) - Unique identifier for the process - **name** (string) - Display name of the process - **value** (string) - Internal identifier (slug) of the process - **description** (string) - Description of the process - **parameters** (array) - List of parameters required for the process - **name** (string) - Name of the parameter - **columnName** (string) - Database column name for the parameter - **displayType** (integer) - Type of display for the parameter - **mandatory** (boolean) - Whether the parameter is required - **default** (any) - Default value for the parameter #### Response Example ```json { "id": 101, "name": "Generate Invoice", "value": "GenerateInvoice", "description": "Generate invoices from orders", "parameters": [ { "name": "OrderID", "columnName": "C_Order_ID", "displayType": 19, "mandatory": true, "default": null }, { "name": "CreateShipment", "columnName": "CreateShipment", "displayType": 20, "mandatory": false, "default": "Y" } ] } ``` ``` -------------------------------- ### Example JSON Response for Available Models Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/02-models.md A sample JSON response listing available iDempiere models, including their names and entity types. ```json [ { "name": "C_Invoice", "tableName": "C_Invoice", "entityType": "D" } ] ``` -------------------------------- ### Read REST Configurations Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/11-configuration.md Retrieves all system configurations starting with 'REST_' from the database and prints their names and values. ```java List configs = new Query(Env.getCtx(), MSysConfig.Table_Name) .addLike("Name", "REST_%") .list(); for (MSysConfig config : configs) { System.out.println(config.getName() + " = " + config.getValue()); } ``` -------------------------------- ### RefreshParameters JSON Example Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/10-types.md Example JSON for the RefreshParameters request body, used for token refresh. ```json { "refreshToken": "refresh_token_abc123xyz" } ``` -------------------------------- ### Response Body for Available Roles Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/01-authentication.md This is an example of the JSON response when retrieving available roles for a client, listing each role with its ID, name, and description. ```json [ { "id": 102, "name": "System Administrator", "description": "Full system access" } ] ``` -------------------------------- ### Authenticate User with OIDC Provider Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/09-oidc.md Example of authenticating a user using an IOIDCProvider instance and retrieving user details. ```java IOIDCProvider provider = // get provider instance AuthenticatedUser user = provider.authenticate(authCode, state); String username = user.getUsername(); String email = user.getEmail(); List roles = user.getRoles(); ``` -------------------------------- ### Response Body for Available Warehouses Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/01-authentication.md This is an example of the JSON response when listing available warehouses, including their ID, name, and value. ```json [ { "id": 103, "name": "Standard Warehouse", "value": "WAREHOUSE_01" } ] ``` -------------------------------- ### GET /v1/processes Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/04-processes.md Retrieves a list of available processes. Supports filtering by process name. ```APIDOC ## GET /v1/processes ### Description Lists available processes. Supports filtering by process name. ### Method GET ### Endpoint /v1/processes ### Parameters #### Query Parameters - **$filter** (String) - Optional - Filter expression on process names ### Response #### Success Response (200 OK) - **id** (integer) - Unique identifier for the process - **name** (string) - Display name of the process - **value** (string) - Internal identifier (slug) of the process - **description** (string) - Description of the process #### Response Example ```json [ { "id": 101, "name": "Generate Invoice", "value": "GenerateInvoice", "description": "Generate invoices from orders" } ] ``` ``` -------------------------------- ### GET /v1/infos Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Lists available info windows. This endpoint can be filtered using the $filter query parameter. ```APIDOC ## GET /v1/infos ### Description List available info windows. ### Method GET ### Endpoint /v1/infos ### Parameters #### Query Parameters - **$filter** (string) - Optional - Filter criteria for info windows. ### Response #### Success Response (200 OK) - **id** (integer) - The unique identifier for the info window. - **name** (string) - The display name of the info window. - **value** (string) - The internal identifier for the info window. ### Response Example ```json [ { "id": 101, "name": "Invoice Info", "value": "InvoiceInfo" } ] ``` ``` -------------------------------- ### GET /v1/windows/{windowSlug} Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/03-windows.md Fetches records from the header tab of a specified window. Supports filtering, sorting, and pagination. ```APIDOC ## GET /v1/windows/{windowSlug} ### Description List records in a window's header tab with pagination. ### Method GET ### Endpoint /v1/windows/{windowSlug} ### Path Parameters - **windowSlug** (String) - Required - Window slug ### Query Parameters - **$filter** (String) - WHERE clause for filtering - **$sort_column** (String) - Column to sort by (prefix with ! for descending) - **$page_no** (int) - Page number (0-indexed) ### Response #### Success Response (200 OK) - **records** (array) - List of records matching the criteria - **id** (integer) - Unique identifier for the record - **[FieldName]** (any) - Fields of the record, names correspond to column names - **pageNumber** (integer) - The current page number - **pageSize** (integer) - The number of records per page - **recordCount** (integer) - The total number of records available - **pageCount** (integer) - The total number of pages ### Response Example ```json { "records": [ { "id": 12345, "DocumentNo": "INV001", "Amount": 1000.00 } ], "pageNumber": 0, "pageSize": 20, "recordCount": 1, "pageCount": 1 } ``` ### Usage Example ``` GET /v1/windows/invoice?$filter=DocStatus%20eq%20'CO'&$sort_column=!DocumentNo&$page_no=0 ``` ``` -------------------------------- ### GET /v1/files/{processUUID}/{filename} Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Download a file generated by a process or report. Requires the process UUID and the filename. ```APIDOC ## GET /v1/files/{processUUID}/{filename} ### Description Download file generated by a process or report. ### Method GET ### Endpoint /v1/files/{processUUID}/{filename} ### Parameters #### Path Parameters - **processUUID** (String) - Yes - UUID from process execution response - **filename** (String) - Yes - Output filename (e.g., "output.pdf") ### Response #### Success Response (200 OK) File content as binary stream. Content-Type varies by file type. #### Error Response - HTTP 404: File not found - HTTP 401: Unauthorized ### Request Example ``` GET /v1/files/550e8400-e29b-41d4-a716-446655440000/invoice.pdf ``` ``` -------------------------------- ### Idempiere REST API Paging Usage Example Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/02-models.md Demonstrates how to create a Paging object, set the active page, and retrieve the total page count for API responses. ```java Paging paging = new Paging(100, 20); // 100 records, 20 per page paging.setActivePage(0); // First page (0-indexed) int pageCount = paging.getPageCount(); // Returns 5 ``` -------------------------------- ### Make a Basic API Request Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/README.md After obtaining an access token, use this cURL command to make a GET request to retrieve data from an API endpoint, such as 'C_Invoice'. ```bash TOKEN="" curl -X GET "http://localhost:8080/rest/v1/models/C_Invoice" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Authenticate User and Get Tokens Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/00-index.md Use this endpoint to authenticate a user and obtain access and refresh tokens. The access token is required for subsequent authenticated requests. ```bash # 1. Get access token curl -X POST http://localhost:8080/rest/v1/auth/tokens \ -H "Content-Type: application/json" \ -d '{ "userName": "admin", "password": "adempiere", "parameters": { "clientId": "11", "roleId": "102", "organizationId": "101", "warehouseId": "103" } }' # Response includes access_token and refresh_token # Use access_token in Authorization header for subsequent requests ``` -------------------------------- ### Get Info Window Details Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Fetches the details of a specific info window, including its columns. Requires the info window's slug. ```java Response getInfo(@PathParam("infoSlug") String infoSlug) ``` -------------------------------- ### Example JSON Response for Multiple Records Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/02-models.md A sample JSON response structure for multiple iDempiere records, including a list of records and pagination details. ```json { "records": [ { "id": 12345, "DocumentNo": "INV001" } ], "recordCount": 1, "pageNumber": 0, "pageSize": 20 } ``` -------------------------------- ### OIDC Authorization Request URL Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/09-oidc.md Example URL for initiating the OIDC authorization flow. The client redirects the user to this URL. ```url https://keycloak.example.com/realms/idempiere/protocol/openid-connect/auth ?client_id=idempiere-rest &redirect_uri=https://idempiere.example.com/auth/callback &response_type=code &scope=openid+profile+email &state=xyz123 ``` -------------------------------- ### Example JSON Response for Single Property Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/02-models.md A sample JSON response for retrieving a single property's value from an iDempiere record. ```json { "property": "Amount", "value": 1000.00 } ``` -------------------------------- ### Configure Postman Environment Variables Source: https://github.com/bxservice/idempiere-rest/blob/master/com.trekglobal.idempiere.rest.api/keycloak/Testing Steps.txt Set up a new Postman environment with variables for 'keycloakHost', 'idempiereHost', and 'clientSecret'. The 'clientSecret' should be copied from the 'rest-api' client credentials in Keycloak. ```text Postman - Create new environment - Add variable keycloakHost, set value to your keycloak server host, for e.g http://localhost:9080 - Add variable idempiereHost, set value to your iDempiere server host, for e.g https://127.0.0.1:8443 - Add variable clientSecret, pass the copied client secret value from clipboard - Save the environment and use it to run your test ``` -------------------------------- ### Deploy REST API Extension Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/00-index.md Deploy the REST API extension to your iDempiere instance. Ensure you are in the iDempiere instance directory. ```bash # In iDempiere instance directory ./update-rest-extensions.sh file:////path/to/com.trekglobal.idempiere.extensions.p2/target/repository ``` -------------------------------- ### Get Window Tabs and Metadata Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/03-windows.md Retrieves the tabs and their metadata for a specific iDempiere window, identified by its slug. Returns an HTTP 404 if the window is not found. ```java Response getTabs(@PathParam("windowSlug") String windowSlug) ``` ```json { "id": 143, "name": "Invoice", "slug": "invoice", "tabs": [ { "id": 218, "name": "Invoice", "slug": "invoice", "tableName": "C_Invoice", "orderByClause": "DocumentNo" }, { "id": 319, "name": "Invoice Line", "slug": "invoice-line", "tableName": "C_InvoiceLine", "parentTab": 218 } ] } ``` -------------------------------- ### GET /v1/auth/roles Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/01-authentication.md Get available roles for a client. ```APIDOC ## GET /v1/auth/roles ### Description Get available roles for a client. ### Method GET ### Endpoint /v1/auth/roles ### Parameters #### Query Parameters - **client** (int) - Yes - Client ID ### Response #### Success Response (200 OK) - **id** (int) - Role ID - **name** (string) - Role name - **description** (string) - Role description ### Response Example ```json [ { "id": 102, "name": "System Administrator", "description": "Full system access" } ] ``` ``` -------------------------------- ### Execute Document Report Request Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/04-processes.md Example of executing a document report. This shows how to specify special properties like record-id, model-name, report-type, and print-format-id for report generation. ```http POST /v1/processes/PrintInvoice Content-Type: application/json { "record-id": 54321, "model-name": "C_Invoice", "report-type": "PDF", "print-format-id": 104 } ``` -------------------------------- ### GET /v1/auth/organizations Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/01-authentication.md Get available organizations for a client and role. ```APIDOC ## GET /v1/auth/organizations ### Description Get available organizations for a client and role. ### Method GET ### Endpoint /v1/auth/organizations ### Parameters #### Query Parameters - **client** (int) - Yes - Client ID - **role** (int) - Yes - Role ID ### Response #### Success Response (200 OK) - **id** (int) - Organization ID - **name** (string) - Organization name - **value** (string) - Organization value ### Response Example ```json [ { "id": 101, "name": "Headquarters", "value": "HQ" } ] ``` ``` -------------------------------- ### GET /v1/auth/warehouses Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/01-authentication.md Get available warehouses for a client, role, and organization. ```APIDOC ## GET /v1/auth/warehouses ### Description Get available warehouses for a client, role, and organization. ### Method GET ### Endpoint /v1/auth/warehouses ### Parameters #### Query Parameters - **client** (int) - Yes - Client ID - **role** (int) - Yes - Role ID - **organization** (int) - Yes - Organization ID ### Response #### Success Response (200 OK) - **id** (int) - Warehouse ID - **name** (string) - Warehouse name - **value** (string) - Warehouse value ### Response Example ```json [ { "id": 103, "name": "Standard Warehouse", "value": "WAREHOUSE_01" } ] ``` ``` -------------------------------- ### Make Authenticated Request to Get Invoices Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/00-index.md Retrieve a list of invoices using an access token obtained from the authentication endpoint. The token is passed in the Authorization header. ```bash # Get list of invoices TOKEN= curl -X GET "http://localhost:8080/rest/v1/models/C_Invoice" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### GET /v1/auth/jwk Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/01-authentication.md Get JWK (JSON Web Key) for JWT validation. ```APIDOC ## GET /v1/auth/jwk ### Description Get JWK (JSON Web Key) for JWT validation. ### Method GET ### Endpoint /v1/auth/jwk ### Response #### Success Response (200 OK) Returns public keys for JWT verification. ### Usage Example Clients can use this endpoint to get public keys for offline JWT validation. ``` -------------------------------- ### Get Upload Status (GET) Source: https://github.com/bxservice/idempiere-rest/blob/master/com.trekglobal.idempiere.rest.api/postman/upload example/test_presigned_url.txt Retrieve the status of an upload using its upload ID. This requires a presigned URL obtained from a previous GET request to the uploads endpoint. Ensure the correct presigned URL is used. ```bash curl -v -H "Content-Type: application/json" -H "Accept: application/json" \ "http://{hostName}/api/{presignedURL}" ``` -------------------------------- ### Example JSON Response for Single Record Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/02-models.md A sample JSON response structure for a single iDempiere record, including its ID, document number, amount, and status. ```json { "id": 12345, "DocumentNo": "INV001", "Amount": 1000.00, "Status": "CO" } ``` -------------------------------- ### Get Form Layout and Parameters (Java) Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/04-processes.md Retrieve the layout and available parameters for a specific iDempiere form using its slug. This is useful for understanding form structure before submission. ```java Response getForm(@PathParam("formSlug") String formSlug) ``` -------------------------------- ### GET /v1/models Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/02-models.md Get a list of available models (tables). Supports filtering by model names. ```APIDOC ## GET /v1/models ### Description Get a list of available models (tables). Supports filtering by model names. ### Method GET ### Endpoint /v1/models ### Parameters #### Query Parameters - **$filter** (String) - Filter expression for model names ### Response #### Success Response (200 OK) - **name** (string) - - **tableName** (string) - - **entityType** (string) - #### Response Example ```json [ { "name": "C_Invoice", "tableName": "C_Invoice", "entityType": "D" } ] ``` ``` -------------------------------- ### Configure Caching Strategy Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/11-configuration.md Enable caching, set Time-To-Live (TTL), maximum size, and cache replacement strategy. ```properties REST_CACHE_ENABLED=Y REST_CACHE_TTL_SECONDS=300 REST_CACHE_MAX_SIZE_MB=200 REST_CACHE_STRATEGY=LRU ``` -------------------------------- ### Execute a System Process Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/00-index.md This endpoint allows for the execution of predefined iDempiere processes. Provide the process name and any necessary parameters in the request body. ```bash curl -X POST http://localhost:8080/rest/v1/processes/GenerateInvoice \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "C_Order_ID": 12345, "CreateShipment": "Y" }' ``` -------------------------------- ### Configure Keycloak Client Source: https://github.com/bxservice/idempiere-rest/blob/master/com.trekglobal.idempiere.rest.api/keycloak/Testing Steps.txt Within the 'GardenWorld' realm, create a client named 'rest-api'. Ensure 'Client authentication' and 'Authorization' are enabled. Use the default authentication flow. ```text Client authentication: on Authorization: on Authentication flow: default ``` -------------------------------- ### Configuration Value Resolution Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/11-configuration.md Demonstrates how to resolve a configuration value by checking system properties, environment variables, and then the SysConfig database, falling back to a default if not found. ```java String secret = System.getProperty("REST_JWT_SECRET"); if (secret == null) { secret = System.getenv("REST_JWT_SECRET"); } if (secret == null) { secret = MSysConfig.getValue("REST_JWT_SECRET", "default"); } ``` -------------------------------- ### Inbound Webhook Request Body Example Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/08-webhooks.md Example JSON structure for an inbound webhook event payload. This is used when sending data to the /v1/webhooks/inbound endpoint. ```json { "eventType": "invoice.created", "timestamp": "2024-01-15T10:30:00Z", "source": "external_system", "payload": { "invoiceNumber": "EX001", "amount": 1000.00, "description": "Invoice from external system" } } ``` -------------------------------- ### GET /v1/workflow/pending Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Retrieves a list of pending workflow activities for the current user. ```APIDOC ## GET /v1/workflow/pending ### Description Get pending workflow activities. ### Method GET ### Endpoint /v1/workflow/pending ### Response #### Success Response (200 OK) - **activities** (array) - A list of pending workflow activities. - **id** (integer) - The unique identifier for the activity. - **workflowName** (string) - The name of the workflow. - **nodeName** (string) - The name of the current node in the workflow. - **recordID** (integer) - The ID of the record associated with the activity. - **tableName** (string) - The name of the table the record belongs to. ### Response Example ```json { "activities": [ { "id": 1001, "workflowName": "Invoice Approval", "nodeName": "Manager Approval", "recordID": 12345, "tableName": "C_Invoice" } ] } ``` ``` -------------------------------- ### Configure Logging Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/11-configuration.md Enable logging, control payload logging, include query parameters, and specify audited events. ```properties REST_LOGGING_ENABLED=Y REST_LOGGING_LOG_PAYLOAD=Y REST_LOGGING_INCLUDE_QUERY_PARAMS=Y REST_LOGGING_AUDIT_EVENTS=CREATE,UPDATE,DELETE ``` -------------------------------- ### Get Workflow Nodes Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Retrieves a list of workflow nodes. Supports filtering. ```java Response getWorkflowNodes( @QueryParam("$filter") String filter ) ``` -------------------------------- ### List Application Servers Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Retrieves a list of all application servers configured in the system. ```APIDOC ## GET /v1/servers ### Description List application servers. ### Method GET ### Endpoint /v1/servers ### Response #### Success Response (200 OK) - **id** (integer) - The unique identifier of the server. - **name** (string) - The name of the server. - **description** (string) - A description of the server. - **isActive** (boolean) - Indicates if the server is active. ### Response Example ```json [ { "id": 1, "name": "MyServer", "description": "Production Server", "isActive": true } ] ``` ``` -------------------------------- ### GET /v1/infos/{infoSlug} Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Retrieves details for a specific info window identified by its slug. ```APIDOC ## GET /v1/infos/{infoSlug} ### Description Get info window details. ### Method GET ### Endpoint /v1/infos/{infoSlug} ### Parameters #### Path Parameters - **infoSlug** (string) - Required - The slug identifier of the info window. ### Response #### Success Response (200 OK) - **id** (integer) - The unique identifier for the info window. - **name** (string) - The display name of the info window. - **columns** (array) - A list of columns available in the info window. - **name** (string) - The name of the column. - **displayType** (integer) - The display type of the column. - **mandatory** (boolean) - Indicates if the column is mandatory. ### Response Example ```json { "id": 101, "name": "Invoice Info", "columns": [ { "name": "DocumentNo", "displayType": 10, "mandatory": true } ] } ``` ``` -------------------------------- ### Get Pending Workflow Activities Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Fetches a list of workflow activities that are currently pending. ```java Response getPendingActivities() ``` -------------------------------- ### Create Keycloak User 'GardenAdmin' Source: https://github.com/bxservice/idempiere-rest/blob/master/com.trekglobal.idempiere.rest.api/keycloak/Testing Steps.txt Create a new user 'GardenAdmin' with the specified email and name. Assign them to the 'HQ' group and set their password. Ensure the 'Temporary' flag is off. ```text Users > Add user - Name: GardenAdmin - Email: admin@gardenworld.com - First Name: GardenAdmin - Join Groups: HQ - Users > GardenAdmin > Credentials > Set password: 123, Temporary: off ``` -------------------------------- ### POST /v1/windows/{windowSlug} Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/03-windows.md Creates a new record in a window's header tab. ```APIDOC ## POST /v1/windows/{windowSlug} ### Description Create a new record in a window's header tab. ### Method POST ### Endpoint /v1/windows/{windowSlug} ### Parameters #### Path Parameters - **windowSlug** (String) - Yes - Window slug #### Request Body JSON with field values. ### Response #### Success Response (201 Created) Returns created record with ID. ``` -------------------------------- ### Get Upload Status Source: https://github.com/bxservice/idempiere-rest/blob/master/com.trekglobal.idempiere.rest.api/postman/upload example/test_presigned_url.txt Retrieves the status and details of a specific upload using its ID. ```APIDOC ## GET api/v1/uploads/{uploadId} ### Description Retrieves the status and details of an ongoing or completed upload. ### Method GET ### Endpoint `/api/v1/uploads/{uploadId}` ### Parameters #### Path Parameters - **uploadId** (string) - The ID of the upload. ### Request Example ```bash curl -v -H "Content-Type: application/json" -H "Accept: application/json" \ "http://{hostName}/api/{presignedURL}" ``` ### Response #### Success Response (200) - **uploadId** (string) - The ID of the upload. - **status** (string) - The current status of the upload (e.g., PENDING, PROCESSING, COMPLETED). - **fileName** (string) - The name of the uploaded file. - **fileSize** (integer) - The total size of the file in bytes. - **chunks** (integer) - The number of chunks uploaded so far. - **totalChunks** (integer) - The total number of chunks expected. #### Response Example ```json { "uploadId": "66f19240-0eed-4c00-b78d-f406a4dde0d3", "status": "PROCESSING", "fileName": "example.jpg", "fileSize": 1024000, "chunks": 5, "totalChunks": 10 } ``` ``` -------------------------------- ### GET /v1/workflow/nodes Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Retrieves a list of available workflow nodes. Can be filtered using the $filter query parameter. ```APIDOC ## GET /v1/workflow/nodes ### Description Get workflow nodes. ### Method GET ### Endpoint /v1/workflow/nodes ### Parameters #### Query Parameters - **$filter** (string) - Optional - Filter criteria for workflow nodes. ### Response #### Success Response (200 OK) - **nodeID** (integer) - The unique identifier for the workflow node. - **name** (string) - The name of the workflow node. - **action** (string) - The action associated with the workflow node. ### Response Example ```json [ { "nodeID": 1, "name": "Approve", "action": "ApprovalRequired" } ] ``` ``` -------------------------------- ### Create Keycloak User 'GardenUser' Source: https://github.com/bxservice/idempiere-rest/blob/master/com.trekglobal.idempiere.rest.api/keycloak/Testing Steps.txt Create a new user 'GardenUser' with the specified email and name. Assign them to the 'HQ' group and set their password. Ensure the 'Temporary' flag is off. ```text Users > Create new user - Name: GardenUser - Email: user@gardenworld.com - First Name: GardenUser - Join Groups: HQ - Users > GardenUser > Credentials > Set password: 123, Temporary: off ``` -------------------------------- ### Configure Per-User Rate Limits Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/11-configuration.md Enable rate limiting and set limits per minute, burst multiplier, and exempt roles. ```properties REST_API_RATE_LIMIT_ENABLED=Y REST_API_RATE_LIMIT_PER_MINUTE=100 REST_API_RATE_LIMIT_BURST_MULTIPLIER=1.5 REST_API_RATE_LIMIT_EXEMPT_ROLES=102,103 ``` -------------------------------- ### Get Form Layout and Parameters Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/04-processes.md Retrieves the layout and available parameters for a specific form, identified by its slug. ```APIDOC ## GET /v1/forms/{formSlug} ### Description Get form layout and parameters. ### Method GET ### Endpoint /v1/forms/{formSlug} ### Path Parameters #### Path Parameters - **formSlug** (String) - Required - The unique slug identifier for the form. ### Response #### Success Response (200 OK) Returns form metadata and available parameters. ``` -------------------------------- ### List Application Servers Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Retrieves a list of all application servers. Returns a 200 OK with a JSON array of server objects. ```java Response getServers() ``` ```json [ { "id": 1, "name": "MyServer", "description": "Production Server", "isActive": true } ] ``` -------------------------------- ### Initiate File Upload Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/07-advanced-resources.md Initiates a chunked file upload session. Provide filename, content type, total size, and target table name. ```json { "filename": "large_file.csv", "contentType": "text/csv", "totalSize": 10485760, "tableName": "AD_Attachment" } ``` -------------------------------- ### Configure Database Connection Pooling Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/11-configuration.md Set minimum and maximum pool sizes, and connection timeouts for database connections. ```properties REST_DB_POOL_MIN_SIZE=5 REST_DB_POOL_MAX_SIZE=20 REST_DB_POOL_TIMEOUT_MS=5000 REST_DB_IDLE_TIMEOUT_MS=600000 ``` -------------------------------- ### Get Reference List Entries Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/04-processes.md Retrieves specific entries for a given reference type. Supports filtering and field selection. ```APIDOC ## GET /v1/reference/{referenceSlug} ### Description Retrieves a list of entries for a specific reference type identified by `referenceSlug`. Supports filtering with `$filter` and selecting specific fields with `$select`. ### Method GET ### Endpoint /v1/reference/{referenceSlug} ### Path Parameters - **referenceSlug** (string) - Required - The unique slug identifying the reference type. ### Query Parameters - **$filter** (string) - Optional - Used to filter the results. - **$select** (string) - Optional - Used to specify which fields to return. ### Response #### Success Response (200 OK) - **id** (integer) - The unique identifier for the reference entry. - **name** (string) - The name of the reference entry (e.g., "Headquarters"). - **description** (string) - A description of the reference entry. - **isActive** (boolean) - Indicates if the reference entry is active. ### Response Example ```json [ { "id": 101, "name": "Headquarters", "description": "Main office", "isActive": true } ] ``` ``` -------------------------------- ### Get JWT Token Issuer Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/06-jwt-tokens.md Retrieves the issuer claim (iss) for JWT tokens. This identifies the entity that issued the token. ```java String issuer = TokenUtils.getTokenIssuer(); ``` -------------------------------- ### POST /v1/processes/{processSlug} Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/04-processes.md Executes a specified process with provided parameters. Can be used for both processes and reports. ```APIDOC ## POST /v1/processes/{processSlug} ### Description Executes a specified process using its slug and a JSON payload containing parameters. This endpoint can also be used to generate reports. ### Method POST ### Endpoint /v1/processes/{processSlug} ### Parameters #### Path Parameters - **processSlug** (String) - Required - Process identifier #### Request Body JSON with process parameters and options. For document processes, includes `record-id`, `table-id`, and `model-name`. For reports, includes `report-type`, `is-summary`, and `print-format-id`. **Special Properties** - **record-id** (int) - Record ID for document processes - **table-id** (int) - AD_Table_ID for document processes - **model-name** (String) - Table name for document processes - **report-type** (String) - Output format: HTML, CSV, PDF, XLS (for reports) - **is-summary** (boolean) - Summary report flag - **print-format-id** (int) - Print format ID for document printing ### Request Example ```json { "C_Order_ID": 12345, "CreateShipment": "Y", "record-id": 54321, "table-id": 259, "model-name": "C_Invoice", "report-type": "PDF", "is-summary": false, "print-format-id": 104 } ``` ### Response #### Success Response (200 OK) - **processUUID** (string) - Unique identifier for the process execution - **isProcessRunning** (boolean) - Indicates if the process is running asynchronously - **summary** (string) - A summary message of the process completion - **resultFile** (object) - Information about the generated result file (if applicable) - **name** (string) - Name of the result file - **path** (string) - Path to the result file on the server - **url** (string) - URL to access the result file #### Response Example ```json { "processUUID": "550e8400-e29b-41d4-a716-446655440000", "isProcessRunning": false, "summary": "Process completed", "resultFile": { "name": "output.pdf", "path": "/path/to/file", "url": "/v1/files/550e8400-e29b-41d4-a716-446655440000/output.pdf" } } ``` ### Error Handling - HTTP 400: Invalid parameters - HTTP 401: Unauthorized - HTTP 404: Process not found - HTTP 500: Process execution error ``` -------------------------------- ### User Authentication - Get Access Token Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/00-index.md Obtain an access token and refresh token by providing user credentials and context parameters. ```APIDOC ## POST /rest/v1/auth/tokens ### Description Authenticates a user and returns access and refresh tokens. ### Method POST ### Endpoint /rest/v1/auth/tokens ### Request Body - **userName** (string) - Required - The username for authentication. - **password** (string) - Required - The password for authentication. - **parameters** (object) - Optional - Additional parameters for authentication context. - **clientId** (string) - Optional - The client ID. - **roleId** (string) - Optional - The role ID. - **organizationId** (string) - Optional - The organization ID. - **warehouseId** (string) - Optional - The warehouse ID. ### Request Example ```json { "userName": "admin", "password": "adempiere", "parameters": { "clientId": "11", "roleId": "102", "organizationId": "101", "warehouseId": "103" } } ``` ### Response #### Success Response (200) - **access_token** (string) - The JWT access token. - **refresh_token** (string) - The JWT refresh token. ### Notes Use the `access_token` in the `Authorization` header for subsequent requests. ``` -------------------------------- ### Keycloak Provider Configuration Properties Source: https://github.com/bxservice/idempiere-rest/blob/master/_autodocs/09-oidc.md System configuration properties required for setting up the Keycloak OIDC provider in iDempiere. ```properties REST_OIDC_PROVIDER=keycloak REST_KEYCLOAK_SERVER_URL=https://keycloak.example.com REST_KEYCLOAK_REALM=idempiere REST_KEYCLOAK_CLIENT_ID=idempiere-rest REST_KEYCLOAK_CLIENT_SECRET=client_secret_key REST_KEYCLOAK_REDIRECT_URI=https://idempiere.example.com/auth/callback ```