Calling Liferay APIs from Camunda

The Liferay Connector enables calling Liferay APIs from your Camunda tasks. It’s a protocol connector built on top of the Camunda HTTP REST connector.

Follow these steps to enable outbound communication from the Camunda Liferay Connector to Liferay’s APIs:

  1. In your Camunda instance, install the Liferay Connector.

  2. In Liferay, authorize the connection to Liferay’s APIs.

    • In Global Menu → Control Panel → OAuth2 Administration, add a new OAuth2 application. Make sure you select Client Credentials under Allowed Authorization Types and a user with appropriate Liferay permissions under Client Credentials User. You can select Headless Server under Client Profile to minimize the authorization scopes that are enabled automatically.
    • Define the needed API scopes for the process.
    • Copy the client ID and secret.

    See Using OAuth2 to Authorize Users for more information. Other forms of authentication are available (e.g., basic user name and password authorization), but OAuth2 is recommended for production environments.

  3. Back in Camunda, add a Task and choose the Liferay Connector template.

  4. Add the Client ID and Secret from the OAuth2 application you created in Liferay.

    In production environments, use Camunda secrets to store credentials securely. Add a separate key/value pair for the client ID and secret. See Using Secrets to learn how to refer to the secrets in the Liferay Connector properties.

  5. Add the Token Endpoint URL following this pattern: https://[Liferay Base URL]/o/oauth2/token

    Authenticate using Liferay's OAuth2 token endpoint.

Next, configure the HTTP Endpoint in the connector:

  1. In the Model Type, choose Custom Objects or Other. The remaining options are slightly different for each case.

  2. Set the Base URL to your Liferay instance’s endpoint.

    For a custom object called Foo with the plural name foos, the value looks like this:

    https://myliferayinstance.com/o/c/foos
    

    Here’s what it looks like if you chose Other Model Type and want to call the headless-admin-user API:

    https://myliferayinstance.com/o/headless-admin-user
    
  3. Set the endpoint to call.

    For a custom object API call you can choose the Operation Type and whether to store the response. Available operation types include Get Object, Get Objects, Create Object, Update Object, Update Object Fields, and Delete Object.

    If you chose Other Model Type, define a custom path, method, headers, and query parameters. For example, to call the getAccountByExternalReferenceCode endpoint with a variable containing the account ERC, you can set this path:

    "/v1.0/accounts/by-external-reference-code/" + accountExternalReferenceCode
    

    In this example, the ERC would likely come to Camunda in the payload from a Liferay object’s webhook action, and stored as a variable in the webhook connector’s configuration. See Triggering Events in Camunda with Liferay Webhooks.

Configure the endpoint.

After configuring the endpoint, you must configure the connector to handle the response.

  1. If desired, set the name of a variable to store the response. By default the response is available in a temporary local variable called response.

  2. To process specific attributes from the response into more granular variables, use a Result Expression. This FEEL expression takes the response and defines some variables:

    = {
        body: response.body,
        dateCreated: response.body.dateCreated,
        id: response.body.id,
        name: response.body.name,
        type: response.body.type,
    }
    

    The original response might look like this:

    {
      "accountContactInformation": {
        "emailAddresses": [],
        "postalAddresses": [],
        "telephones": [],
        "webUrls": []
      },
      "actions": {
        "move-organization-accounts": {
          "method": "PATCH",
          "href": "http://localhost:8080/o/headless-admin-user/v1.0/organizations/move-accounts/34621/{targetOrganizationId}"
        },
        "replace-by-external-reference-code": {
          "method": "PUT",
          "href": "http://localhost:8080/o/headless-admin-user/v1.0/accounts/by-external-reference-code/{externalReferenceCode}"
        }
      },
      "customFields": [],
      "dateCreated": "2025-05-06T05:15:21Z",
      "dateModified": "2025-05-06T05:15:21Z",
      "defaultBillingAddressId": 0,
      "defaultShippingAddressId": 0,
      "description": "",
      "domains": [],
      "externalReferenceCode": "6b074194-e3d8-3a6f-6fc7-981c6f1253a6",
      "id": 34621,
      "logoId": 0,
      "logoURL": "/image/organization_logo?img_id=0&t=1747731138313",
      "name": "Account1",
      "numberOfUsers": 2,
      "organizationExternalReferenceCodes": [],
      "organizationIds": [],
      "parentAccountId": 0,
      "status": 0,
      "taxId": "",
      "type": "business"
    }
    

In this example, the Result Expression extracts the body, dateCreated, id, name, and type attributes from the response variable and assigns them to process variables with the same names. You can then use these variables in the steps of your workflow process. The syntax for accessing attributes in the result expression varies depending on the structure of your response object. See the FEEL Context Expression documentation for more information.

With the outbound connection and OAuth2 configured, you can call Liferay’s APIs from Camunda and work with the response.

Troubleshooting

Investigate these areas if you experience issues with the Liferay connector:

  • Make sure your Liferay credentials are correct.

  • Make sure your configuration properties are set correctly.

  • Check the logs for any error messages.

  • Contact Camunda support if you need further assistance.