xFlow
  • Overview
    • Introduction
    • Core Features
    • Architecture
      • High Level Architecture
      • Tech Stack
      • Deployment Flexibility
      • Performance and Scalability
      • Security Compliance
  • Getting Started
    • Installation
    • Quick Start
    • Configuration
  • Core Concepts
    • Serverless Workflow Specification
    • Workflow data handling
    • Workflow Expressions
    • Error handling
    • Input and Output schema definition
    • User Task
    • User Forms
      • Lowcode Form
      • Advanced User Form
    • AI Agents in Enterprise Business Processes
    • Comparisons
      • BPMN2
  • Developer Guide
    • Architecture
    • API Reference
    • Workflow States Reference
      • Event State
      • Operation State
      • Switch State
      • Parallel State
      • Inject State
      • ForEach State
      • Callback State
      • UserTask State
      • AIAgent State
      • AIAgentProxy State
      • UserProxyAgent State
      • AI Outbound Agent State
    • Workflow Functions
      • REST
      • GraphQL
      • Custom
        • Built-in Functions
        • Lowcoder Query Function
      • Function Auth
    • Workflow Secrets
    • Integrations
    • Workflow Modeler
    • Frontend Development
      • Forms
        • Lowcode Form
        • Advanced User Form
    • Serverless Workflow Development
      • Operation State
      • Switch State
      • Parallel State
      • ForEach State
      • Callback State
      • User Task State
    • AI Agent Development
      • AI Agent
        • Predefined LLM
        • LLM Configuration
        • Multi LLM Configuration
        • Chat Memory
        • Tools
        • Data Output
        • Agent Outcomes
      • AI Agent Proxy
        • AI Agents Integration
      • User Proxy Agent
      • xChatBot Integration
  • Examples
    • Basic Examples
    • Advanced Examples
      • Loan Approval Workflow
      • QMS AP Workflow
  • Administration
    • Monitoring and Logging
    • Security
    • Performance Tuning
  • Extensions and Customizations
    • Plugins and Add-ons
  • Troubleshooting
    • Common Issues
    • FAQs
  • Release Notes
    • Version History
    • Upcoming Features
  • Support
    • Contact Information
    • Community
Powered by GitBook
On this page
  1. Developer Guide
  2. Workflow Functions

REST

PreviousWorkflow FunctionsNextGraphQL

Last updated 1 year ago

The specification also supports describing REST invocations in the functions definition using .

Here is an example function definition for REST requests with method GET and request target corresponding with /users/{id}:

{
  "functions":[
    {
      "name":"queryUserById",
      "operation": {
        "/users": {
          "get": {
            "parameters": [{
              "name": "id",
              "in": "path",
              "required": true 
            }]
          }
        }
      },
      "type":"rest"
    }
  ]
}

The function can be referenced during workflow execution when the invocation of the REST service is desired. For example:

{
  "states":[
    {
      "name":"QueryUserInfo",
      "type":"operation",
      "actions":[
        {
          "functionRef":"queryUserById",
          "arguments":{
            "id":"${ .user.id }"
          }
        }
      ],
      "end":true
    }
  ]
}

Example of the POST request sending the state data as part of the body:

{
  "functions":[
    {
      "name": "createUser",
      "type": "rest",
      "operation": {
        "/users": {
          "post": {
            "requestBody": {
              "content": {
                "application/json": {
                  "schema": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"                     
                      },
                      "email": {
                        "type": "string"
                      }
                    },
                    "required": ["name", "email"]
                  }
                }
              }
            }
          }
        }
      }
    }
  ]
}

You can reference the createUser function and filter the input data to invoke it. Given the workflow input data:

{
  "order":{
    "id":"1234N",
    "products":[
      {
        "name":"Product 1"
      }
    ]
  },
  "user":{
    "name":"John Doe",
    "email":"john@doe.com"
  }
}

Function invocation example:

{
  "states":[
    {
      "name":"CreateNewUser",
      "type":"operation",
      "actions":[
        {
          "functionRef":"createUser",
          "actionDataFilter":{
            "fromStateData":"${ .user }",
            "toStateData":"${ .user.id }"
          }
        }
      ],
      "end":true
    }
  ]
}

In this case, only the contents of the user attribute will be passed to the function. The user ID returned by the REST request body will then be added to the state data:

{
  "order":{
    "id":"1234N",
    "products":[
      {
        "name":"Product 1"
      }
    ]
  },
  "user":{
    "id":"5678U",
    "name":"John Doe",
    "email":"john@doe.com"
  }
}

Note that the Function Definition's operation property must follow the specification definition.

Note that the requestBody is described inline rather than a reference to an external document.

The specification does not support the since its redundat to function Auth Definition. If provided, this field is ignored.

OpenAPI Paths Object
URI Template
OpenAPI Paths Object
content attribute
Security Requirement Object