How to use a variable in the Request body while using REST Connector in Camunda modeler

I’m trying to get the values from a user task using a form and then I want to fetch the variable from the form and use it in the payload of the API call in the REST Connector task.

Are variables currently supported in the body of a REST Connector? If yes Could you please provide me the syntax to fetch the variable value in the payload?

Hi @Anantya_Mary!

Welcome to the forum!

Yes, variables are supported in the REST Connector body. There is no special syntax to retrieve the variables, as you can type in the request body as a FEEL Expression. Here is an example of what this may look like:

Screenshot 2024-02-07 at 1.43.59 PM

1 Like

Hi @sholstine

This is json format of the embedded form I’m using in the user task

{
  "executionPlatform": "Camunda Cloud",
  "executionPlatformVersion": "8.4.0",
  "exporter": {
    "name": "Camunda Web Modeler",
    "version": "24fdc40"
  },
  "schemaVersion": 15,
  "id": "itemAttributes",
  "components": [
    {
      "label": "category",
      "type": "textfield",
      "layout": {
        "row": "Row_0zqt3bn",
        "columns": null
      },
      "id": "Field_0jcwecb",
      "key": "category",
      "properties": { }
    },
    {
      "label": "manufacturer",
      "type": "textfield",
      "layout": {
        "row": "Row_11x4rvv",
        "columns": null
      },
      "id": "Field_18f6lgs",
      "key": "manufacturer",
      "properties": { }
    },
    {
      "label": "model",
      "type": "textfield",
      "layout": {
        "row": "Row_0vv9twq",
        "columns": null
      },
      "id": "Field_0dgxe12",
      "key": "model"
    },
    {
      "label": "grade",
      "type": "textfield",
      "layout": {
        "row": "Row_1bjwjzx",
        "columns": null
      },
      "id": "Field_0s8td1r",
      "key": "grade"
    },
    {
      "label": "color",
      "type": "textfield",
      "layout": {
        "row": "Row_0bvk6bh",
        "columns": null
      },
      "id": "Field_1slawip",
      "key": "color"
    },
    {
      "label": "itemNumberWarehouse",
      "type": "textfield",
      "layout": {
        "row": "Row_1q0vzu8",
        "columns": null
      },
      "id": "Field_0h8j6w3",
      "key": "itemNumberWarehouse"
    }
  ],
  "type": "default"
}

How do I get these values in my REST Connector body? Does the form key automatically define the variable?

When I tried calling the key value directly inside the request body it still throws mw json parsing error

Hi @Anantya_Mary,

Yes, the form key creates a local variable that can be used in your process.

Can you share what your request body looks like?

Hey @sholstine

The issue got resolved as soon as I enabled feel expression in the request body. Thanks for the help!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.